Created
June 3, 2014 09:25
-
-
Save dstogov/6b7cda09d8311077fb25 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Zend/zend_hash.h b/Zend/zend_hash.h | |
index c196134..0952dbe 100644 | |
--- a/Zend/zend_hash.h | |
+++ b/Zend/zend_hash.h | |
@@ -285,11 +285,27 @@ static inline int _zend_handle_numeric_str(const char *key, int length, ulong *i | |
} | |
} | |
+static inline int _zend_handle_numeric(zend_string *key, ulong *idx) | |
+{ | |
+ if (GC_FLAGS(key) & (IS_STR_NUMERIC|IS_STR_NON_NUMERIC)) { | |
+ *idx = key->h; | |
+ return GC_FLAGS(key) & IS_STR_NUMERIC; | |
+ } | |
+ if (_zend_handle_numeric_str(key->val, key->len, idx)) { | |
+ GC_FLAGS(key) |= IS_STR_NUMERIC; | |
+ key->h = *idx; | |
+ return 1; | |
+ } else { | |
+ GC_FLAGS(key) |= IS_STR_NON_NUMERIC; | |
+ 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) | |
+ _zend_handle_numeric(key, &idx) | |
static inline zval *zend_hash_find_ind(const HashTable *ht, zend_string *key) | |
diff --git a/Zend/zend_types.h b/Zend/zend_types.h | |
index 232fcba..248b4e5 100644 | |
--- a/Zend/zend_types.h | |
+++ b/Zend/zend_types.h | |
@@ -313,6 +313,9 @@ static inline zend_uchar zval_get_type(const zval* pz) { | |
#define IS_STR_CONSTANT (1<<3) /* constant index */ | |
#define IS_STR_CONSTANT_UNQUALIFIED (1<<4) /* the same as IS_CONSTANT_UNQUALIFIED */ | |
+#define IS_STR_NUMERIC (1<<5) | |
+#define IS_STR_NON_NUMERIC (1<<6) | |
+ | |
/* object flags (zval.value->gc.u.flags) */ | |
#define IS_OBJ_APPLY_COUNT 0x07 | |
#define IS_OBJ_DESTRUCTOR_CALLED (1<<3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment