]> granicus.if.org Git - php/commitdiff
Simplified and optimized ZEND_HANDLE_NUMERIC()
authorDmitry Stogov <dmitry@zend.com>
Tue, 3 Jun 2014 09:10:42 +0000 (13:10 +0400)
committerDmitry Stogov <dmitry@zend.com>
Tue, 3 Jun 2014 09:10:42 +0000 (13:10 +0400)
Zend/zend_compile.c
Zend/zend_execute.c
Zend/zend_hash.h
Zend/zend_vm_def.h
Zend/zend_vm_execute.h
ext/opcache/Optimizer/zend_optimizer.c
ext/spl/spl_engine.c

index ea75c1503ae88f2423c26d99d020aa7611b9e706..fda1c7606e9027c78e108b44b44b76916925149c 100644 (file)
@@ -811,10 +811,8 @@ void fetch_array_dim(znode *result, znode *parent, znode *dim TSRMLS_DC) /* {{{
        SET_NODE(opline.op2, dim);
        if (opline.op2_type == IS_CONST && Z_TYPE(CONSTANT(opline.op2.constant)) == IS_STRING) {
                ulong index;
-               int numeric = 0;
 
-               ZEND_HANDLE_NUMERIC_EX(Z_STRVAL(CONSTANT(opline.op2.constant)), Z_STRLEN(CONSTANT(opline.op2.constant))+1, index, numeric = 1);
-               if (numeric) {
+               if (ZEND_HANDLE_NUMERIC(Z_STR(CONSTANT(opline.op2.constant)), index)) {
                        zval_dtor(&CONSTANT(opline.op2.constant));
                        ZVAL_LONG(&CONSTANT(opline.op2.constant), index);
                }
@@ -5872,11 +5870,9 @@ void zend_do_init_array(znode *result, znode *expr, znode *offset, zend_bool is_
                        SET_NODE(opline->op2, offset);
                        if (opline->op2_type == IS_CONST && Z_TYPE(CONSTANT(opline->op2.constant)) == IS_STRING) {
                                ulong index;
-                               int numeric = 0;
 
                                opline->extended_value |= ZEND_ARRAY_NOT_PACKED;
-                               ZEND_HANDLE_NUMERIC_EX(Z_STRVAL(CONSTANT(opline->op2.constant)), Z_STRLEN(CONSTANT(opline->op2.constant))+1, index, numeric = 1);
-                               if (numeric) {
+                               if (ZEND_HANDLE_NUMERIC(Z_STR(CONSTANT(opline->op2.constant)), index)) {
                                        zval_dtor(&CONSTANT(opline->op2.constant));
                                        ZVAL_LONG(&CONSTANT(opline->op2.constant), index);
                                }
@@ -5904,11 +5900,9 @@ void zend_do_add_array_element(znode *result, znode *expr, znode *offset, zend_b
                SET_NODE(opline->op2, offset);
                if (opline->op2_type == IS_CONST && Z_TYPE(CONSTANT(opline->op2.constant)) == IS_STRING) {
                        ulong index;
-                       int numeric = 0;
 
                        init_opline->extended_value |= ZEND_ARRAY_NOT_PACKED;
-                       ZEND_HANDLE_NUMERIC_EX(Z_STRVAL(CONSTANT(opline->op2.constant)), Z_STRLEN(CONSTANT(opline->op2.constant))+1, index, numeric = 1);
-                       if (numeric) {
+                       if (ZEND_HANDLE_NUMERIC(Z_STR(CONSTANT(opline->op2.constant)), index)) {
                                zval_dtor(&CONSTANT(opline->op2.constant));
                                ZVAL_LONG(&CONSTANT(opline->op2.constant), index);
                        }
index a9b9c92b0e55c3d06c587ccd06b9af7b240baebd..80d4fbb5db04dcd09a98c66870f6f3280ea7e8b6 100644 (file)
@@ -1045,7 +1045,9 @@ num_index:
        } else if (EXPECTED(Z_TYPE_P(dim) == IS_STRING)) {
                offset_key = Z_STR_P(dim);
                if (dim_type != IS_CONST) {
-                       ZEND_HANDLE_NUMERIC_EX(offset_key->val, offset_key->len+1, hval, goto num_index);
+                       if (ZEND_HANDLE_NUMERIC(offset_key, hval)) {
+                               goto num_index;
+                       }
                }
 str_index:
                retval = zend_hash_find(ht, offset_key);
index 8660f8b6b70f0f596212e3ba5d9a948027d716d8..c196134657d3c96fea540c337d698cc10676db18 100644 (file)
@@ -235,46 +235,61 @@ END_EXTERN_C()
 #define ZEND_INIT_SYMTABLE_EX(ht, n, persistent)                       \
        zend_hash_init(ht, n, NULL, ZVAL_PTR_DTOR, persistent)
 
-#define ZEND_HANDLE_NUMERIC_EX(key, length, idx, func) do {                                    \
-       register const char *tmp = key;                                                                                 \
-                                                                                                                                                       \
-       if (*tmp == '-') {                                                                                                              \
-               tmp++;                                                                                                                          \
-       }                                                                                                                                               \
-       if (*tmp >= '0' && *tmp <= '9') { /* possibly a numeric index */                \
-               const char *end = key + length - 1;                                                                     \
-                                                                                                                                                       \
-               if ((*end != '\0') /* not a null terminated string */                           \
-                || (*tmp == '0' && length > 2) /* numbers with leading zeros */        \
-                || (end - tmp > MAX_LENGTH_OF_LONG - 1) /* number too long */          \
-                || (SIZEOF_LONG == 4 &&                                                                                        \
-                    end - tmp == MAX_LENGTH_OF_LONG - 1 &&                                                     \
-                    *tmp > '2')) { /* overflow */                                                                      \
-                       break;                                                                                                                  \
-               }                                                                                                                                       \
-               idx = (*tmp - '0');                                                                                                     \
-               while (++tmp != end && *tmp >= '0' && *tmp <= '9') {                            \
-                       idx = (idx * 10) + (*tmp - '0');                                                                \
-               }                                                                                                                                       \
-               if (tmp == end) {                                                                                                       \
-                       if (*key == '-') {                                                                                              \
-                               if (idx-1 > LONG_MAX) { /* overflow */                                          \
-                                       break;                                                                                                  \
-                               }                                                                                                                       \
-                               idx = 0 - idx;                                                                                  \
-                       } else if (idx > LONG_MAX) { /* overflow */                                             \
-                               break;                                                                                                          \
-                       }                                                                                                                               \
-                       func;                                                                                                                   \
-               }                                                                                                                                       \
-       }                                                                                                                                               \
-} while (0)
-
-#define ZEND_HANDLE_NUMERIC(key, length, func) do {                                                    \
-       ulong idx;                                                                                                                              \
-                                                                                                                                                       \
-       ZEND_HANDLE_NUMERIC_EX(key, length, idx, return func);                                  \
-} while (0)
+static inline int _zend_handle_numeric_str(const char *key, int length, ulong *idx)
+{
+       register const char *tmp = key;
+       const char *end;
+
+       if (*tmp > '9') {
+               return 0;
+       } else if (*tmp < '0') {
+               if (*tmp != '-') {
+                       return 0;
+               }
+               tmp++;
+               if (*tmp > '9' || *tmp < '0') {
+                       return 0;
+               }
+       }
+
+       /* possibly a numeric index */
+       end = key + length;
+
+       if ((*end != '\0') /* not a null terminated string */
+        || (*tmp == '0' && length > 1) /* numbers with leading zeros */
+        || (end - tmp > MAX_LENGTH_OF_LONG - 1) /* number too long */
+        || (SIZEOF_LONG == 4 &&
+            end - tmp == MAX_LENGTH_OF_LONG - 1 &&
+            *tmp > '2')) { /* overflow */
+               return 0;
+       }
+       *idx = (*tmp - '0');
+       while (1) {
+               ++tmp;
+               if (tmp == end) {
+                       if (*key == '-') {
+                               if (*idx-1 > LONG_MAX) { /* overflow */
+                                       return 0;
+                               }
+                               *idx = 0 - *idx;
+                       } else if (*idx > LONG_MAX) { /* overflow */
+                               return 0;
+                       }
+                       return 1;
+               }
+               if (*tmp <= '9' && *tmp >= '0') {
+                       *idx = (*idx * 10) + (*tmp - '0');
+               } else {
+                       return 0;
+               }
+       }
+}
+
+#define ZEND_HANDLE_NUMERIC_STR(key, length, idx) \
+       _zend_handle_numeric_str(key, length, &idx)
+
+#define ZEND_HANDLE_NUMERIC(key, idx) \
+       _zend_handle_numeric_str((key)->val, (key)->len, &idx)
 
 
 static inline zval *zend_hash_find_ind(const HashTable *ht, zend_string *key)
@@ -307,92 +322,157 @@ static inline zval *zend_hash_str_find_ind(const HashTable *ht, const char *str,
 
 static inline zval *zend_symtable_update(HashTable *ht, zend_string *key, zval *pData)
 {
-       ZEND_HANDLE_NUMERIC(key->val, key->len+1, zend_hash_index_update(ht, idx, pData));
-       return zend_hash_update(ht, key, pData);
+       ulong idx;
+
+       if (ZEND_HANDLE_NUMERIC(key, idx)) {
+               return zend_hash_index_update(ht, idx, pData);
+       } else {
+               return zend_hash_update(ht, key, pData);
+       }
 }
 
 
 static inline zval *zend_symtable_update_ind(HashTable *ht, zend_string *key, zval *pData)
 {
-       ZEND_HANDLE_NUMERIC(key->val, key->len+1, zend_hash_index_update(ht, idx, pData));
-       return zend_hash_update_ind(ht, key, pData);
+       ulong idx;
+
+       if (ZEND_HANDLE_NUMERIC(key, idx)) {
+               return zend_hash_index_update(ht, idx, pData);
+       } else {
+               return zend_hash_update_ind(ht, key, pData);
+       }
 }
 
 
 static inline int zend_symtable_del(HashTable *ht, zend_string *key)
 {
-       ZEND_HANDLE_NUMERIC(key->val, key->len+1, zend_hash_index_del(ht, idx));
-       return zend_hash_del(ht, key);
+       ulong idx;
+
+       if (ZEND_HANDLE_NUMERIC(key, idx)) {
+               return zend_hash_index_del(ht, idx);
+       } else {
+               return zend_hash_del(ht, key);
+       }
 }
 
 
 static inline int zend_symtable_del_ind(HashTable *ht, zend_string *key)
 {
-       ZEND_HANDLE_NUMERIC(key->val, key->len+1, zend_hash_index_del(ht, idx));
-       return zend_hash_del_ind(ht, key);
+       ulong idx;
+
+       if (ZEND_HANDLE_NUMERIC(key, idx)) {
+               return zend_hash_index_del(ht, idx);
+       } else {
+               return zend_hash_del_ind(ht, key);
+       }
 }
 
 
 static inline zval *zend_symtable_find(const HashTable *ht, zend_string *key)
 {
-       ZEND_HANDLE_NUMERIC(key->val, key->len+1, zend_hash_index_find(ht, idx));
-       return zend_hash_find(ht, key);
+       ulong idx;
+
+       if (ZEND_HANDLE_NUMERIC(key, idx)) {
+               return zend_hash_index_find(ht, idx);
+       } else {
+               return zend_hash_find(ht, key);
+       }
 }
 
 
 static inline zval *zend_symtable_find_ind(const HashTable *ht, zend_string *key)
 {
-       ZEND_HANDLE_NUMERIC(key->val, key->len+1, zend_hash_index_find(ht, idx));
-       return zend_hash_find_ind(ht, key);
+       ulong idx;
+
+       if (ZEND_HANDLE_NUMERIC(key, idx)) {
+               return zend_hash_index_find(ht, idx);
+       } else {
+               return zend_hash_find_ind(ht, key);
+       }
 }
 
 
 static inline int zend_symtable_exists(HashTable *ht, zend_string *key)
 {
-       ZEND_HANDLE_NUMERIC(key->val, key->len+1, zend_hash_index_exists(ht, idx));
-       return zend_hash_exists(ht, key);
+       ulong idx;
+
+       if (ZEND_HANDLE_NUMERIC(key, idx)) {
+               return zend_hash_index_exists(ht, idx);
+       } else {
+               return zend_hash_exists(ht, key);
+       }
 }
 
 
 static inline zval *zend_symtable_str_update(HashTable *ht, const char *str, int len, zval *pData)
 {
-       ZEND_HANDLE_NUMERIC(str, len+1, zend_hash_index_update(ht, idx, pData));
-       return zend_hash_str_update(ht, str, len, pData);
+       ulong idx;
+
+       if (ZEND_HANDLE_NUMERIC_STR(str, len, idx)) {
+               return zend_hash_index_update(ht, idx, pData);
+       } else {
+               return zend_hash_str_update(ht, str, len, pData);
+       }
 }
 
 
 static inline zval *zend_symtable_str_update_ind(HashTable *ht, const char *str, int len, zval *pData)
 {
-       ZEND_HANDLE_NUMERIC(str, len+1, zend_hash_index_update(ht, idx, pData));
-       return zend_hash_str_update_ind(ht, str, len, pData);
+       ulong idx;
+
+       if (ZEND_HANDLE_NUMERIC_STR(str, len, idx)) {
+               return zend_hash_index_update(ht, idx, pData);
+       } else {
+               return zend_hash_str_update_ind(ht, str, len, pData);
+       }
 }
 
 
 static inline int zend_symtable_str_del(HashTable *ht, const char *str, int len)
 {
-       ZEND_HANDLE_NUMERIC(str, len+1, zend_hash_index_del(ht, idx));
-       return zend_hash_str_del(ht, str, len);
+       ulong idx;
+
+       if (ZEND_HANDLE_NUMERIC_STR(str, len, idx)) {
+               return zend_hash_index_del(ht, idx);
+       } else {
+               return zend_hash_str_del(ht, str, len);
+       }
 }
 
 
 static inline int zend_symtable_str_del_ind(HashTable *ht, const char *str, int len)
 {
-       ZEND_HANDLE_NUMERIC(str, len+1, zend_hash_index_del(ht, idx));
-       return zend_hash_str_del_ind(ht, str, len);
+       ulong idx;
+
+       if (ZEND_HANDLE_NUMERIC_STR(str, len, idx)) {
+               return zend_hash_index_del(ht, idx);
+       } else {
+               return zend_hash_str_del_ind(ht, str, len);
+       }
 }
 
 
 static inline zval *zend_symtable_str_find(HashTable *ht, const char *str, int len)
 {
-       ZEND_HANDLE_NUMERIC(str, len+1, zend_hash_index_find(ht, idx));
-       return zend_hash_str_find(ht, str, len);
+       ulong idx;
+
+       if (ZEND_HANDLE_NUMERIC_STR(str, len, idx)) {
+               return zend_hash_index_find(ht, idx);
+       } else {
+               return zend_hash_str_find(ht, str, len);
+       }
 }
 
 
 static inline int zend_symtable_str_exists(HashTable *ht, const char *str, int len)
 {
-       ZEND_HANDLE_NUMERIC(str, len+1, zend_hash_index_exists(ht, idx));
-       return zend_hash_str_exists(ht, str, len);
+       ulong idx;
+
+       if (ZEND_HANDLE_NUMERIC_STR(str, len, idx)) {
+               return zend_hash_index_exists(ht, idx);
+       } else {
+               return zend_hash_str_exists(ht, str, len);
+       }
 }
 
 static inline void *zend_hash_add_ptr(HashTable *ht, zend_string *key, void *pData)
index 3329b14949189f8c559a74dc7164ab93d3b10acc..4f87f5b37525db34b9cf25fe7d22b1b0de08c908 100644 (file)
@@ -3770,7 +3770,9 @@ ZEND_VM_C_LABEL(num_index):
                        case IS_STRING:
                                str = Z_STR_P(offset);
                                if (OP2_TYPE != IS_CONST) {
-                                       ZEND_HANDLE_NUMERIC_EX(str->val, str->len+1, hval, ZEND_VM_C_GOTO(num_index));
+                                       if (ZEND_HANDLE_NUMERIC(str, hval)) {
+                                               ZEND_VM_C_GOTO(num_index);
+                                       }
                                }
 ZEND_VM_C_LABEL(str_index):                            
                                zend_hash_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), str, expr_ptr);
@@ -4141,7 +4143,9 @@ ZEND_VM_C_LABEL(num_index_dim):
                                                if (Z_REFCOUNTED_P(offset)) Z_ADDREF_P(offset);
                                        }
                                        if (OP2_TYPE != IS_CONST) {
-                                               ZEND_HANDLE_NUMERIC_EX(Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, hval, ZEND_VM_C_GOTO(numeric_index_dim));
+                                               if (ZEND_HANDLE_NUMERIC(Z_STR_P(offset), hval)) {
+                                                       ZEND_VM_C_GOTO(numeric_index_dim);
+                                               }
                                        }
                                        if (ht == &EG(symbol_table).ht) {
                                                zend_delete_global_variable(Z_STR_P(offset) TSRMLS_CC);
@@ -4664,7 +4668,9 @@ ZEND_VM_C_LABEL(num_index_prop):
                        case IS_STRING:
                                str = Z_STR_P(offset);
                                if (OP2_TYPE != IS_CONST) {
-                                       ZEND_HANDLE_NUMERIC_EX(str->val, str->len+1, hval, ZEND_VM_C_GOTO(num_index_prop));
+                                       if (ZEND_HANDLE_NUMERIC(str, hval)) {
+                                               ZEND_VM_C_GOTO(num_index_prop);
+                                       }
                                }
 ZEND_VM_C_LABEL(str_index_prop):
                                value = zend_hash_find_ind(ht, str);
index 316011fef84d3f5d6fc84a0a6aee0c5e5a5eba0d..4a66c7390d2150fd95207a4edcaef5564db2a5da 100644 (file)
@@ -4027,7 +4027,9 @@ num_index:
                        case IS_STRING:
                                str = Z_STR_P(offset);
                                if (IS_CONST != IS_CONST) {
-                                       ZEND_HANDLE_NUMERIC_EX(str->val, str->len+1, hval, goto num_index);
+                                       if (ZEND_HANDLE_NUMERIC(str, hval)) {
+                                               goto num_index;
+                                       }
                                }
 str_index:
                                zend_hash_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), str, expr_ptr);
@@ -4895,7 +4897,9 @@ num_index:
                        case IS_STRING:
                                str = Z_STR_P(offset);
                                if (IS_TMP_VAR != IS_CONST) {
-                                       ZEND_HANDLE_NUMERIC_EX(str->val, str->len+1, hval, goto num_index);
+                                       if (ZEND_HANDLE_NUMERIC(str, hval)) {
+                                               goto num_index;
+                                       }
                                }
 str_index:
                                zend_hash_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), str, expr_ptr);
@@ -5727,7 +5731,9 @@ num_index:
                        case IS_STRING:
                                str = Z_STR_P(offset);
                                if (IS_VAR != IS_CONST) {
-                                       ZEND_HANDLE_NUMERIC_EX(str->val, str->len+1, hval, goto num_index);
+                                       if (ZEND_HANDLE_NUMERIC(str, hval)) {
+                                               goto num_index;
+                                       }
                                }
 str_index:
                                zend_hash_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), str, expr_ptr);
@@ -6402,7 +6408,9 @@ num_index:
                        case IS_STRING:
                                str = Z_STR_P(offset);
                                if (IS_UNUSED != IS_CONST) {
-                                       ZEND_HANDLE_NUMERIC_EX(str->val, str->len+1, hval, goto num_index);
+                                       if (ZEND_HANDLE_NUMERIC(str, hval)) {
+                                               goto num_index;
+                                       }
                                }
 str_index:
                                zend_hash_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), str, expr_ptr);
@@ -7292,7 +7300,9 @@ num_index:
                        case IS_STRING:
                                str = Z_STR_P(offset);
                                if (IS_CV != IS_CONST) {
-                                       ZEND_HANDLE_NUMERIC_EX(str->val, str->len+1, hval, goto num_index);
+                                       if (ZEND_HANDLE_NUMERIC(str, hval)) {
+                                               goto num_index;
+                                       }
                                }
 str_index:
                                zend_hash_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), str, expr_ptr);
@@ -9114,7 +9124,9 @@ num_index:
                        case IS_STRING:
                                str = Z_STR_P(offset);
                                if (IS_CONST != IS_CONST) {
-                                       ZEND_HANDLE_NUMERIC_EX(str->val, str->len+1, hval, goto num_index);
+                                       if (ZEND_HANDLE_NUMERIC(str, hval)) {
+                                               goto num_index;
+                                       }
                                }
 str_index:
                                zend_hash_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), str, expr_ptr);
@@ -9949,7 +9961,9 @@ num_index:
                        case IS_STRING:
                                str = Z_STR_P(offset);
                                if (IS_TMP_VAR != IS_CONST) {
-                                       ZEND_HANDLE_NUMERIC_EX(str->val, str->len+1, hval, goto num_index);
+                                       if (ZEND_HANDLE_NUMERIC(str, hval)) {
+                                               goto num_index;
+                                       }
                                }
 str_index:
                                zend_hash_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), str, expr_ptr);
@@ -10781,7 +10795,9 @@ num_index:
                        case IS_STRING:
                                str = Z_STR_P(offset);
                                if (IS_VAR != IS_CONST) {
-                                       ZEND_HANDLE_NUMERIC_EX(str->val, str->len+1, hval, goto num_index);
+                                       if (ZEND_HANDLE_NUMERIC(str, hval)) {
+                                               goto num_index;
+                                       }
                                }
 str_index:
                                zend_hash_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), str, expr_ptr);
@@ -11342,7 +11358,9 @@ num_index:
                        case IS_STRING:
                                str = Z_STR_P(offset);
                                if (IS_UNUSED != IS_CONST) {
-                                       ZEND_HANDLE_NUMERIC_EX(str->val, str->len+1, hval, goto num_index);
+                                       if (ZEND_HANDLE_NUMERIC(str, hval)) {
+                                               goto num_index;
+                                       }
                                }
 str_index:
                                zend_hash_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), str, expr_ptr);
@@ -12159,7 +12177,9 @@ num_index:
                        case IS_STRING:
                                str = Z_STR_P(offset);
                                if (IS_CV != IS_CONST) {
-                                       ZEND_HANDLE_NUMERIC_EX(str->val, str->len+1, hval, goto num_index);
+                                       if (ZEND_HANDLE_NUMERIC(str, hval)) {
+                                               goto num_index;
+                                       }
                                }
 str_index:
                                zend_hash_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), str, expr_ptr);
@@ -15548,7 +15568,9 @@ num_index:
                        case IS_STRING:
                                str = Z_STR_P(offset);
                                if (IS_CONST != IS_CONST) {
-                                       ZEND_HANDLE_NUMERIC_EX(str->val, str->len+1, hval, goto num_index);
+                                       if (ZEND_HANDLE_NUMERIC(str, hval)) {
+                                               goto num_index;
+                                       }
                                }
 str_index:
                                zend_hash_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), str, expr_ptr);
@@ -15718,7 +15740,9 @@ num_index_dim:
                                                if (Z_REFCOUNTED_P(offset)) Z_ADDREF_P(offset);
                                        }
                                        if (IS_CONST != IS_CONST) {
-                                               ZEND_HANDLE_NUMERIC_EX(Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, hval, goto numeric_index_dim);
+                                               if (ZEND_HANDLE_NUMERIC(Z_STR_P(offset), hval)) {
+                                                       goto numeric_index_dim;
+                                               }
                                        }
                                        if (ht == &EG(symbol_table).ht) {
                                                zend_delete_global_variable(Z_STR_P(offset) TSRMLS_CC);
@@ -15923,7 +15947,9 @@ num_index_prop:
                        case IS_STRING:
                                str = Z_STR_P(offset);
                                if (IS_CONST != IS_CONST) {
-                                       ZEND_HANDLE_NUMERIC_EX(str->val, str->len+1, hval, goto num_index_prop);
+                                       if (ZEND_HANDLE_NUMERIC(str, hval)) {
+                                               goto num_index_prop;
+                                       }
                                }
 str_index_prop:
                                value = zend_hash_find_ind(ht, str);
@@ -17684,7 +17710,9 @@ num_index:
                        case IS_STRING:
                                str = Z_STR_P(offset);
                                if (IS_TMP_VAR != IS_CONST) {
-                                       ZEND_HANDLE_NUMERIC_EX(str->val, str->len+1, hval, goto num_index);
+                                       if (ZEND_HANDLE_NUMERIC(str, hval)) {
+                                               goto num_index;
+                                       }
                                }
 str_index:
                                zend_hash_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), str, expr_ptr);
@@ -17782,7 +17810,9 @@ num_index_dim:
                                                if (Z_REFCOUNTED_P(offset)) Z_ADDREF_P(offset);
                                        }
                                        if (IS_TMP_VAR != IS_CONST) {
-                                               ZEND_HANDLE_NUMERIC_EX(Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, hval, goto numeric_index_dim);
+                                               if (ZEND_HANDLE_NUMERIC(Z_STR_P(offset), hval)) {
+                                                       goto numeric_index_dim;
+                                               }
                                        }
                                        if (ht == &EG(symbol_table).ht) {
                                                zend_delete_global_variable(Z_STR_P(offset) TSRMLS_CC);
@@ -17908,7 +17938,9 @@ num_index_prop:
                        case IS_STRING:
                                str = Z_STR_P(offset);
                                if (IS_TMP_VAR != IS_CONST) {
-                                       ZEND_HANDLE_NUMERIC_EX(str->val, str->len+1, hval, goto num_index_prop);
+                                       if (ZEND_HANDLE_NUMERIC(str, hval)) {
+                                               goto num_index_prop;
+                                       }
                                }
 str_index_prop:
                                value = zend_hash_find_ind(ht, str);
@@ -19883,7 +19915,9 @@ num_index:
                        case IS_STRING:
                                str = Z_STR_P(offset);
                                if (IS_VAR != IS_CONST) {
-                                       ZEND_HANDLE_NUMERIC_EX(str->val, str->len+1, hval, goto num_index);
+                                       if (ZEND_HANDLE_NUMERIC(str, hval)) {
+                                               goto num_index;
+                                       }
                                }
 str_index:
                                zend_hash_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), str, expr_ptr);
@@ -20053,7 +20087,9 @@ num_index_dim:
                                                if (Z_REFCOUNTED_P(offset)) Z_ADDREF_P(offset);
                                        }
                                        if (IS_VAR != IS_CONST) {
-                                               ZEND_HANDLE_NUMERIC_EX(Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, hval, goto numeric_index_dim);
+                                               if (ZEND_HANDLE_NUMERIC(Z_STR_P(offset), hval)) {
+                                                       goto numeric_index_dim;
+                                               }
                                        }
                                        if (ht == &EG(symbol_table).ht) {
                                                zend_delete_global_variable(Z_STR_P(offset) TSRMLS_CC);
@@ -20258,7 +20294,9 @@ num_index_prop:
                        case IS_STRING:
                                str = Z_STR_P(offset);
                                if (IS_VAR != IS_CONST) {
-                                       ZEND_HANDLE_NUMERIC_EX(str->val, str->len+1, hval, goto num_index_prop);
+                                       if (ZEND_HANDLE_NUMERIC(str, hval)) {
+                                               goto num_index_prop;
+                                       }
                                }
 str_index_prop:
                                value = zend_hash_find_ind(ht, str);
@@ -21336,7 +21374,9 @@ num_index:
                        case IS_STRING:
                                str = Z_STR_P(offset);
                                if (IS_UNUSED != IS_CONST) {
-                                       ZEND_HANDLE_NUMERIC_EX(str->val, str->len+1, hval, goto num_index);
+                                       if (ZEND_HANDLE_NUMERIC(str, hval)) {
+                                               goto num_index;
+                                       }
                                }
 str_index:
                                zend_hash_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), str, expr_ptr);
@@ -23259,7 +23299,9 @@ num_index:
                        case IS_STRING:
                                str = Z_STR_P(offset);
                                if (IS_CV != IS_CONST) {
-                                       ZEND_HANDLE_NUMERIC_EX(str->val, str->len+1, hval, goto num_index);
+                                       if (ZEND_HANDLE_NUMERIC(str, hval)) {
+                                               goto num_index;
+                                       }
                                }
 str_index:
                                zend_hash_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), str, expr_ptr);
@@ -23357,7 +23399,9 @@ num_index_dim:
                                                if (Z_REFCOUNTED_P(offset)) Z_ADDREF_P(offset);
                                        }
                                        if (IS_CV != IS_CONST) {
-                                               ZEND_HANDLE_NUMERIC_EX(Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, hval, goto numeric_index_dim);
+                                               if (ZEND_HANDLE_NUMERIC(Z_STR_P(offset), hval)) {
+                                                       goto numeric_index_dim;
+                                               }
                                        }
                                        if (ht == &EG(symbol_table).ht) {
                                                zend_delete_global_variable(Z_STR_P(offset) TSRMLS_CC);
@@ -23483,7 +23527,9 @@ num_index_prop:
                        case IS_STRING:
                                str = Z_STR_P(offset);
                                if (IS_CV != IS_CONST) {
-                                       ZEND_HANDLE_NUMERIC_EX(str->val, str->len+1, hval, goto num_index_prop);
+                                       if (ZEND_HANDLE_NUMERIC(str, hval)) {
+                                               goto num_index_prop;
+                                       }
                                }
 str_index_prop:
                                value = zend_hash_find_ind(ht, str);
@@ -24815,7 +24861,9 @@ num_index_dim:
                                                if (Z_REFCOUNTED_P(offset)) Z_ADDREF_P(offset);
                                        }
                                        if (IS_CONST != IS_CONST) {
-                                               ZEND_HANDLE_NUMERIC_EX(Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, hval, goto numeric_index_dim);
+                                               if (ZEND_HANDLE_NUMERIC(Z_STR_P(offset), hval)) {
+                                                       goto numeric_index_dim;
+                                               }
                                        }
                                        if (ht == &EG(symbol_table).ht) {
                                                zend_delete_global_variable(Z_STR_P(offset) TSRMLS_CC);
@@ -24941,7 +24989,9 @@ num_index_prop:
                        case IS_STRING:
                                str = Z_STR_P(offset);
                                if (IS_CONST != IS_CONST) {
-                                       ZEND_HANDLE_NUMERIC_EX(str->val, str->len+1, hval, goto num_index_prop);
+                                       if (ZEND_HANDLE_NUMERIC(str, hval)) {
+                                               goto num_index_prop;
+                                       }
                                }
 str_index_prop:
                                value = zend_hash_find_ind(ht, str);
@@ -26097,7 +26147,9 @@ num_index_dim:
                                                if (Z_REFCOUNTED_P(offset)) Z_ADDREF_P(offset);
                                        }
                                        if (IS_TMP_VAR != IS_CONST) {
-                                               ZEND_HANDLE_NUMERIC_EX(Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, hval, goto numeric_index_dim);
+                                               if (ZEND_HANDLE_NUMERIC(Z_STR_P(offset), hval)) {
+                                                       goto numeric_index_dim;
+                                               }
                                        }
                                        if (ht == &EG(symbol_table).ht) {
                                                zend_delete_global_variable(Z_STR_P(offset) TSRMLS_CC);
@@ -26223,7 +26275,9 @@ num_index_prop:
                        case IS_STRING:
                                str = Z_STR_P(offset);
                                if (IS_TMP_VAR != IS_CONST) {
-                                       ZEND_HANDLE_NUMERIC_EX(str->val, str->len+1, hval, goto num_index_prop);
+                                       if (ZEND_HANDLE_NUMERIC(str, hval)) {
+                                               goto num_index_prop;
+                                       }
                                }
 str_index_prop:
                                value = zend_hash_find_ind(ht, str);
@@ -27381,7 +27435,9 @@ num_index_dim:
                                                if (Z_REFCOUNTED_P(offset)) Z_ADDREF_P(offset);
                                        }
                                        if (IS_VAR != IS_CONST) {
-                                               ZEND_HANDLE_NUMERIC_EX(Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, hval, goto numeric_index_dim);
+                                               if (ZEND_HANDLE_NUMERIC(Z_STR_P(offset), hval)) {
+                                                       goto numeric_index_dim;
+                                               }
                                        }
                                        if (ht == &EG(symbol_table).ht) {
                                                zend_delete_global_variable(Z_STR_P(offset) TSRMLS_CC);
@@ -27507,7 +27563,9 @@ num_index_prop:
                        case IS_STRING:
                                str = Z_STR_P(offset);
                                if (IS_VAR != IS_CONST) {
-                                       ZEND_HANDLE_NUMERIC_EX(str->val, str->len+1, hval, goto num_index_prop);
+                                       if (ZEND_HANDLE_NUMERIC(str, hval)) {
+                                               goto num_index_prop;
+                                       }
                                }
 str_index_prop:
                                value = zend_hash_find_ind(ht, str);
@@ -29180,7 +29238,9 @@ num_index_dim:
                                                if (Z_REFCOUNTED_P(offset)) Z_ADDREF_P(offset);
                                        }
                                        if (IS_CV != IS_CONST) {
-                                               ZEND_HANDLE_NUMERIC_EX(Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, hval, goto numeric_index_dim);
+                                               if (ZEND_HANDLE_NUMERIC(Z_STR_P(offset), hval)) {
+                                                       goto numeric_index_dim;
+                                               }
                                        }
                                        if (ht == &EG(symbol_table).ht) {
                                                zend_delete_global_variable(Z_STR_P(offset) TSRMLS_CC);
@@ -29306,7 +29366,9 @@ num_index_prop:
                        case IS_STRING:
                                str = Z_STR_P(offset);
                                if (IS_CV != IS_CONST) {
-                                       ZEND_HANDLE_NUMERIC_EX(str->val, str->len+1, hval, goto num_index_prop);
+                                       if (ZEND_HANDLE_NUMERIC(str, hval)) {
+                                               goto num_index_prop;
+                                       }
                                }
 str_index_prop:
                                value = zend_hash_find_ind(ht, str);
@@ -32348,7 +32410,9 @@ num_index:
                        case IS_STRING:
                                str = Z_STR_P(offset);
                                if (IS_CONST != IS_CONST) {
-                                       ZEND_HANDLE_NUMERIC_EX(str->val, str->len+1, hval, goto num_index);
+                                       if (ZEND_HANDLE_NUMERIC(str, hval)) {
+                                               goto num_index;
+                                       }
                                }
 str_index:
                                zend_hash_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), str, expr_ptr);
@@ -32518,7 +32582,9 @@ num_index_dim:
                                                if (Z_REFCOUNTED_P(offset)) Z_ADDREF_P(offset);
                                        }
                                        if (IS_CONST != IS_CONST) {
-                                               ZEND_HANDLE_NUMERIC_EX(Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, hval, goto numeric_index_dim);
+                                               if (ZEND_HANDLE_NUMERIC(Z_STR_P(offset), hval)) {
+                                                       goto numeric_index_dim;
+                                               }
                                        }
                                        if (ht == &EG(symbol_table).ht) {
                                                zend_delete_global_variable(Z_STR_P(offset) TSRMLS_CC);
@@ -32723,7 +32789,9 @@ num_index_prop:
                        case IS_STRING:
                                str = Z_STR_P(offset);
                                if (IS_CONST != IS_CONST) {
-                                       ZEND_HANDLE_NUMERIC_EX(str->val, str->len+1, hval, goto num_index_prop);
+                                       if (ZEND_HANDLE_NUMERIC(str, hval)) {
+                                               goto num_index_prop;
+                                       }
                                }
 str_index_prop:
                                value = zend_hash_find_ind(ht, str);
@@ -34367,7 +34435,9 @@ num_index:
                        case IS_STRING:
                                str = Z_STR_P(offset);
                                if (IS_TMP_VAR != IS_CONST) {
-                                       ZEND_HANDLE_NUMERIC_EX(str->val, str->len+1, hval, goto num_index);
+                                       if (ZEND_HANDLE_NUMERIC(str, hval)) {
+                                               goto num_index;
+                                       }
                                }
 str_index:
                                zend_hash_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), str, expr_ptr);
@@ -34465,7 +34535,9 @@ num_index_dim:
                                                if (Z_REFCOUNTED_P(offset)) Z_ADDREF_P(offset);
                                        }
                                        if (IS_TMP_VAR != IS_CONST) {
-                                               ZEND_HANDLE_NUMERIC_EX(Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, hval, goto numeric_index_dim);
+                                               if (ZEND_HANDLE_NUMERIC(Z_STR_P(offset), hval)) {
+                                                       goto numeric_index_dim;
+                                               }
                                        }
                                        if (ht == &EG(symbol_table).ht) {
                                                zend_delete_global_variable(Z_STR_P(offset) TSRMLS_CC);
@@ -34591,7 +34663,9 @@ num_index_prop:
                        case IS_STRING:
                                str = Z_STR_P(offset);
                                if (IS_TMP_VAR != IS_CONST) {
-                                       ZEND_HANDLE_NUMERIC_EX(str->val, str->len+1, hval, goto num_index_prop);
+                                       if (ZEND_HANDLE_NUMERIC(str, hval)) {
+                                               goto num_index_prop;
+                                       }
                                }
 str_index_prop:
                                value = zend_hash_find_ind(ht, str);
@@ -36448,7 +36522,9 @@ num_index:
                        case IS_STRING:
                                str = Z_STR_P(offset);
                                if (IS_VAR != IS_CONST) {
-                                       ZEND_HANDLE_NUMERIC_EX(str->val, str->len+1, hval, goto num_index);
+                                       if (ZEND_HANDLE_NUMERIC(str, hval)) {
+                                               goto num_index;
+                                       }
                                }
 str_index:
                                zend_hash_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), str, expr_ptr);
@@ -36618,7 +36694,9 @@ num_index_dim:
                                                if (Z_REFCOUNTED_P(offset)) Z_ADDREF_P(offset);
                                        }
                                        if (IS_VAR != IS_CONST) {
-                                               ZEND_HANDLE_NUMERIC_EX(Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, hval, goto numeric_index_dim);
+                                               if (ZEND_HANDLE_NUMERIC(Z_STR_P(offset), hval)) {
+                                                       goto numeric_index_dim;
+                                               }
                                        }
                                        if (ht == &EG(symbol_table).ht) {
                                                zend_delete_global_variable(Z_STR_P(offset) TSRMLS_CC);
@@ -36823,7 +36901,9 @@ num_index_prop:
                        case IS_STRING:
                                str = Z_STR_P(offset);
                                if (IS_VAR != IS_CONST) {
-                                       ZEND_HANDLE_NUMERIC_EX(str->val, str->len+1, hval, goto num_index_prop);
+                                       if (ZEND_HANDLE_NUMERIC(str, hval)) {
+                                               goto num_index_prop;
+                                       }
                                }
 str_index_prop:
                                value = zend_hash_find_ind(ht, str);
@@ -37785,7 +37865,9 @@ num_index:
                        case IS_STRING:
                                str = Z_STR_P(offset);
                                if (IS_UNUSED != IS_CONST) {
-                                       ZEND_HANDLE_NUMERIC_EX(str->val, str->len+1, hval, goto num_index);
+                                       if (ZEND_HANDLE_NUMERIC(str, hval)) {
+                                               goto num_index;
+                                       }
                                }
 str_index:
                                zend_hash_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), str, expr_ptr);
@@ -39572,7 +39654,9 @@ num_index:
                        case IS_STRING:
                                str = Z_STR_P(offset);
                                if (IS_CV != IS_CONST) {
-                                       ZEND_HANDLE_NUMERIC_EX(str->val, str->len+1, hval, goto num_index);
+                                       if (ZEND_HANDLE_NUMERIC(str, hval)) {
+                                               goto num_index;
+                                       }
                                }
 str_index:
                                zend_hash_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), str, expr_ptr);
@@ -39670,7 +39754,9 @@ num_index_dim:
                                                if (Z_REFCOUNTED_P(offset)) Z_ADDREF_P(offset);
                                        }
                                        if (IS_CV != IS_CONST) {
-                                               ZEND_HANDLE_NUMERIC_EX(Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, hval, goto numeric_index_dim);
+                                               if (ZEND_HANDLE_NUMERIC(Z_STR_P(offset), hval)) {
+                                                       goto numeric_index_dim;
+                                               }
                                        }
                                        if (ht == &EG(symbol_table).ht) {
                                                zend_delete_global_variable(Z_STR_P(offset) TSRMLS_CC);
@@ -39796,7 +39882,9 @@ num_index_prop:
                        case IS_STRING:
                                str = Z_STR_P(offset);
                                if (IS_CV != IS_CONST) {
-                                       ZEND_HANDLE_NUMERIC_EX(str->val, str->len+1, hval, goto num_index_prop);
+                                       if (ZEND_HANDLE_NUMERIC(str, hval)) {
+                                               goto num_index_prop;
+                                       }
                                }
 str_index_prop:
                                value = zend_hash_find_ind(ht, str);
index 0c68cc14d5494ae1b4e43bd3efb39fca2d18cb59..657a3f4b52a76eddf8256a67b8e729ca92560b97 100644 (file)
@@ -297,10 +297,8 @@ static void update_op2_const(zend_op_array *op_array,
 check_numeric:
                                {
                                        ulong index;
-                                       int numeric = 0;
 
-                                       ZEND_HANDLE_NUMERIC_EX(Z_STRVAL_P(val), Z_STRLEN_P(val)+1, index, numeric = 1);
-                                       if (numeric) {
+                                       if (ZEND_HANDLE_NUMERIC(Z_STR_P(val), index)) {
                                                zval_dtor(val);
                                                ZVAL_LONG(val, index);
                                                op_array->literals[opline->op2.constant] = *val;
index a2f36534327114a4346de72ee9fbdcf0147c5f23..0cfcb8ee1822f16a9d4325adfde3e8941cb53d87 100644 (file)
@@ -42,9 +42,13 @@ PHPAPI void spl_instantiate(zend_class_entry *pce, zval *object TSRMLS_DC)
 
 PHPAPI long spl_offset_convert_to_long(zval *offset TSRMLS_DC) /* {{{ */
 {
+       ulong idx;
+
        switch (Z_TYPE_P(offset)) {
        case IS_STRING:
-               ZEND_HANDLE_NUMERIC(Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, idx);
+               if (ZEND_HANDLE_NUMERIC(Z_STR_P(offset), idx)) {
+                       return idx;
+               }
                break;
        case IS_DOUBLE:
                return (long)Z_DVAL_P(offset);