Skip to content

Commit d3592be

Browse files
committed
Remove conditional definitions for zend_engine 2
1 parent 5ddc557 commit d3592be

File tree

1 file changed

+0
-74
lines changed

1 file changed

+0
-74
lines changed

src/contrib/php_array_api.h

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,11 @@
2525
#include "zend_hash.h"
2626
#include "zend_list.h"
2727

28-
#ifdef ZEND_ENGINE_3
2928
# define PAA_LENGTH_ADJ(l) (l)
3029
# define PAA_SYM_EXISTS zend_symtable_str_exists
3130
# define PAA_SYM_DEL zend_symtable_str_del
3231
# define PAA_LONG zend_long
3332
# define PAA_ULONG zend_ulong
34-
#else
35-
# define PAA_LENGTH_ADJ(l) (l+1)
36-
# define PAA_SYM_EXISTS zend_symtable_exists
37-
# define PAA_SYM_DEL zend_symtable_del
38-
# define PAA_LONG long
39-
# define PAA_ULONG ulong
40-
#endif
4133

4234
/**
4335
* All APIs in this file follow a general format:
@@ -89,15 +81,9 @@ zend_bool php_array_exists(zval *zarr, const char *key) {
8981
PAA_SYM_EXISTS(Z_ARRVAL_P(zarr), key, PAA_LENGTH_ADJ(len))
9082
static inline
9183
zend_bool php_array_existsl_safe(zval *zarr, const char *key, int key_len) {
92-
#ifdef ZEND_ENGINE_3
9384
zend_string *keystr = zend_string_init(key, key_len, 0);
9485
zend_bool ret = zend_symtable_exists(Z_ARRVAL_P(zarr), keystr);
9586
zend_string_release(keystr);
96-
#else
97-
char *k = estrndup(key, key_len);
98-
zend_bool ret = zend_symtable_exists(Z_ARRVAL_P(zarr), k, key_len + 1);
99-
efree(k);
100-
#endif
10187
return ret;
10288
}
10389
#define php_array_existsn(zarr, idx) \
@@ -107,14 +93,10 @@ zend_bool php_array_existsz(zval *zarr, zval *key) {
10793
switch (Z_TYPE_P(key)) {
10894
case IS_NULL:
10995
return php_array_existsc(zarr, "");
110-
#ifdef ZEND_ENGINE_3
11196
case IS_FALSE:
11297
return zend_hash_index_exists(Z_ARRVAL_P(zarr), 0);
11398
case IS_TRUE:
11499
return zend_hash_index_exists(Z_ARRVAL_P(zarr), 1);
115-
#else
116-
case IS_BOOL: /* fallthrough */
117-
#endif
118100
case IS_LONG:
119101
return zend_hash_index_exists(Z_ARRVAL_P(zarr), Z_LVAL_P(key));
120102
case IS_DOUBLE:
@@ -174,17 +156,7 @@ zend_bool php_array_existsz(zval *zarr, zval *key) {
174156
*/
175157
static inline
176158
zval *php_array_fetchl(zval *zarr, const char *key, int key_len) {
177-
#ifdef ZEND_ENGINE_3
178159
return zend_symtable_str_find(Z_ARRVAL_P(zarr), key, key_len);
179-
#else
180-
zval **ppzval;
181-
if (FAILURE == zend_symtable_find(Z_ARRVAL_P(zarr),
182-
key, key_len + 1,
183-
(void**)&ppzval)) {
184-
return NULL;
185-
}
186-
return *ppzval;
187-
#endif
188160
}
189161
static inline
190162
zval *php_array_fetch(zval *zarr, const char *key) {
@@ -193,43 +165,24 @@ zval *php_array_fetch(zval *zarr, const char *key) {
193165
#define php_array_fetchc(zarr, litstr) php_array_fetchl(zarr, litstr, sizeof(litstr)-1)
194166
static inline
195167
zval *php_array_fetchl_safe(zval *zarr, const char *key, int key_len) {
196-
#ifdef ZEND_ENGINE_3
197168
zend_string *keystr = zend_string_init(key, key_len, 0);
198169
zval *ret = zend_symtable_find(Z_ARRVAL_P(zarr), keystr);
199170
zend_string_release(keystr);
200-
#else
201-
char *k = estrndup(key, key_len);
202-
zval *ret = php_array_fetchl(zarr, k, key_len);
203-
efree(k);
204-
#endif
205171
return ret;
206172
}
207173
static inline
208174
zval *php_array_fetchn(zval *zarr, PAA_ULONG idx) {
209-
#ifdef ZEND_ENGINE_3
210175
return zend_hash_index_find(Z_ARRVAL_P(zarr), idx);
211-
#else
212-
zval **ppzval;
213-
if (FAILURE == zend_hash_index_find(Z_ARRVAL_P(zarr),
214-
idx, (void**)&ppzval)) {
215-
return NULL;
216-
}
217-
return *ppzval;
218-
#endif
219176
}
220177
static inline
221178
zval *php_array_fetchz(zval *zarr, zval *key) {
222179
switch (Z_TYPE_P(key)) {
223180
case IS_NULL:
224181
return php_array_fetchn(zarr, 0);
225-
#ifdef ZEND_ENGINE_3
226182
case IS_FALSE:
227183
return php_array_fetchn(zarr, 0);
228184
case IS_TRUE:
229185
return php_array_fetchn(zarr, 1);
230-
#else
231-
case IS_BOOL: /* fallthrough */
232-
#endif
233186
case IS_LONG:
234187
return php_array_fetchn(zarr, Z_LVAL_P(key));
235188
case IS_DOUBLE:
@@ -288,12 +241,8 @@ PAA_LONG php_array_zval_to_long(zval *z) {
288241
ZVAL_DEREF(z);
289242
goto try_again;
290243
case IS_NULL: return 0;
291-
#ifdef ZEND_ENGINE_3
292244
case IS_FALSE: return 0;
293245
case IS_TRUE: return 1;
294-
#else
295-
case IS_BOOL: return Z_BVAL_P(z);
296-
#endif
297246
case IS_LONG: return Z_LVAL_P(z);
298247
default:
299248
{
@@ -326,12 +275,8 @@ double php_array_zval_to_double(zval *z) {
326275
ZVAL_DEREF(z);
327276
goto try_again;
328277
case IS_NULL: return 0.0;
329-
#ifdef ZEND_ENGINE_3
330278
case IS_FALSE: return 0.0;
331279
case IS_TRUE: return 1.0;
332-
#else
333-
case IS_BOOL: return (double)Z_BVAL_P(z);
334-
#endif
335280
case IS_LONG: return (double)Z_LVAL_P(z);
336281
case IS_DOUBLE: return Z_DVAL_P(z);
337282
default:
@@ -381,11 +326,7 @@ char *php_array_zval_to_string(zval *z, int *plen, zend_bool *pfree) {
381326
zval c = *z;
382327
zval_copy_ctor(&c);
383328
convert_to_string(&c);
384-
#ifdef ZEND_ENGINE_3
385329
*pfree = ! IS_INTERNED(Z_STR(c));
386-
#else
387-
*pfree = ! IS_INTERNED(Z_STRVAL(c));
388-
#endif
389330
*plen = Z_STRLEN(c);
390331
return Z_STRVAL(c);
391332
}
@@ -454,18 +395,7 @@ PHP_ARRAY_FETCH_TYPE_MAP(zval*, array)
454395
*/
455396
static inline
456397
void *php_array_zval_to_resource(zval *z, int le) {
457-
#ifdef ZEND_ENGINE_3
458398
return zend_fetch_resource_ex(z, NULL, le);
459-
#else
460-
void *ret;
461-
int rtype;
462-
if (!z || Z_TYPE_P(z) != IS_RESOURCE) { return NULL; }
463-
ret = zend_list_find(Z_RESVAL_P(z), &rtype);
464-
if (!ret || (rtype != le)) {
465-
return NULL;
466-
}
467-
return ret;
468-
#endif
469399
}
470400
#define php_array_fetch_resource(zarr, key, le) \
471401
php_array_zval_to_resource(php_array_fetch(zarr, key), le)
@@ -543,16 +473,12 @@ static inline void php_array_unsetz(zval *zarr, zval *key) {
543473
case IS_NULL:
544474
zend_hash_index_del(Z_ARRVAL_P(zarr), 0);
545475
return;
546-
#ifdef ZEND_ENGINE_3
547476
case IS_FALSE:
548477
zend_hash_index_del(Z_ARRVAL_P(zarr), 0);
549478
return;
550479
case IS_TRUE:
551480
zend_hash_index_del(Z_ARRVAL_P(zarr), 1);
552481
return;
553-
#else
554-
case IS_BOOL: /* fallthrough */
555-
#endif
556482
case IS_LONG:
557483
zend_hash_index_del(Z_ARRVAL_P(zarr), Z_LVAL_P(key));
558484
return;

0 commit comments

Comments
 (0)