diff options
author | Rasmus Lerdorf <rasmus@php.net> | 2014-10-16 21:28:40 -0700 |
---|---|---|
committer | Rasmus Lerdorf <rasmus@php.net> | 2014-10-16 21:28:40 -0700 |
commit | a9d6556971a435f71eabf142d8fb814382f3b6ac (patch) | |
tree | 4fecce88bbc1bc3259856eb0314d780184de85eb /Zend/zend_string.c | |
parent | 86674b5837bffe4486714f9661620020ee498f3b (diff) | |
parent | 176b8d7ca3aef3a172d8e429627c98e0328d02d8 (diff) | |
download | php-git-a9d6556971a435f71eabf142d8fb814382f3b6ac.tar.gz |
Merge branch 'master' of git.php.net:php-src
* 'master' of git.php.net:php-src: (1132 commits)
Micro optimizations for isset/empty
Micro optimization for zend_hash_next_index_insert_new()
Fix array_keys() on $GLOBALS
Fix procedural finfo calls in methods
Fix allocator for 64bit zend_long with 32bit long
Use intptr_t for zend_intptr_t typedef
Fix format strings in zend_alloc
Drop zend_long64 in favor of int64_t
Removed deprecated fields
NEWS
cleanup NEWS
removing the NEWS entry as we had to revert this fix for now
Revert "Merge branch 'PHP-5.5' into PHP-5.6"
Revert "fix TS build"
Revert "Merge branch 'PHP-5.4' into PHP-5.5"
Revert "Bug #67965: Fix blocking behavior in non-blocking crypto streams"
Revert "Bug #41631: Fix regression from first attempt (6569db8)"
NEWS
Fixed Bug #65171 imagescale() fails
Fixed bug #68234
...
Diffstat (limited to 'Zend/zend_string.c')
-rw-r--r-- | Zend/zend_string.c | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/Zend/zend_string.c b/Zend/zend_string.c index 5a4f4e1fc5..1833bbd241 100644 --- a/Zend/zend_string.c +++ b/Zend/zend_string.c @@ -29,40 +29,36 @@ static zend_string *zend_new_interned_string_int(zend_string *str TSRMLS_DC); static void zend_interned_strings_snapshot_int(TSRMLS_D); static void zend_interned_strings_restore_int(TSRMLS_D); -ZEND_API zend_uint_t zend_hash_func(const char *str, zend_size_t len) +ZEND_API zend_ulong zend_hash_func(const char *str, size_t len) { return zend_inline_hash_func(str, len); } +#ifndef ZTS static void _str_dtor(zval *zv) { zend_string *str = Z_STR_P(zv); GC_FLAGS(str) &= ~IS_STR_INTERNED; GC_REFCOUNT(str) = 1; } +#endif void zend_interned_strings_init(TSRMLS_D) { +#ifndef ZTS zend_string *str; -#ifndef ZTS zend_hash_init(&CG(interned_strings), 1024, NULL, _str_dtor, 1); CG(interned_strings).nTableMask = CG(interned_strings).nTableSize - 1; CG(interned_strings).arData = (Bucket*) pecalloc(CG(interned_strings).nTableSize, sizeof(Bucket), 1); - CG(interned_strings).arHash = (zend_uint*) pecalloc(CG(interned_strings).nTableSize, sizeof(zend_uint), 1); - memset(CG(interned_strings).arHash, INVALID_IDX, CG(interned_strings).nTableSize * sizeof(zend_uint)); + CG(interned_strings).arHash = (uint32_t*) pecalloc(CG(interned_strings).nTableSize, sizeof(uint32_t), 1); + memset(CG(interned_strings).arHash, INVALID_IDX, CG(interned_strings).nTableSize * sizeof(uint32_t)); /* interned empty string */ - str = STR_ALLOC(sizeof("")-1, 1); + str = zend_string_alloc(sizeof("")-1, 1); str->val[0] = '\000'; CG(empty_string) = zend_new_interned_string_int(str TSRMLS_CC); -#else - str = STR_ALLOC(sizeof("")-1, 1); - str->val[0] = '\000'; - STR_HASH_VAL(str); - str->gc.u.v.flags |= IS_STR_INTERNED; - CG(empty_string) = str; #endif /* one char strings (the actual interned strings are going to be created by ext/opcache) */ @@ -77,15 +73,13 @@ void zend_interned_strings_dtor(TSRMLS_D) { #ifndef ZTS zend_hash_destroy(&CG(interned_strings)); -#else - free(CG(empty_string)); #endif } static zend_string *zend_new_interned_string_int(zend_string *str TSRMLS_DC) { #ifndef ZTS - zend_uint_t h; + zend_ulong h; uint nIndex; uint idx; Bucket *p; @@ -94,14 +88,14 @@ static zend_string *zend_new_interned_string_int(zend_string *str TSRMLS_DC) return str; } - h = STR_HASH_VAL(str); + h = zend_string_hash_val(str); nIndex = h & CG(interned_strings).nTableMask; idx = CG(interned_strings).arHash[nIndex]; while (idx != INVALID_IDX) { p = CG(interned_strings).arData + idx; if ((p->h == h) && (p->key->len == str->len)) { if (!memcmp(p->key->val, str->val, str->len)) { - STR_RELEASE(str); + zend_string_release(str); return p->key; } } @@ -114,7 +108,7 @@ static zend_string *zend_new_interned_string_int(zend_string *str TSRMLS_DC) if (CG(interned_strings).nNumUsed >= CG(interned_strings).nTableSize) { if ((CG(interned_strings).nTableSize << 1) > 0) { /* Let's double the table size */ Bucket *d = (Bucket *) perealloc_recoverable(CG(interned_strings).arData, (CG(interned_strings).nTableSize << 1) * sizeof(Bucket), 1); - zend_uint *h = (zend_uint *) perealloc_recoverable(CG(interned_strings).arHash, (CG(interned_strings).nTableSize << 1) * sizeof(zend_uint), 1); + uint32_t *h = (uint32_t *) perealloc_recoverable(CG(interned_strings).arHash, (CG(interned_strings).nTableSize << 1) * sizeof(uint32_t), 1); if (d && h) { HANDLE_BLOCK_INTERRUPTIONS(); @@ -182,7 +176,7 @@ static void zend_interned_strings_restore_int(TSRMLS_D) GC_FLAGS(p->key) &= ~IS_STR_INTERNED; GC_REFCOUNT(p->key) = 1; - STR_FREE(p->key); + zend_string_free(p->key); nIndex = p->h & CG(interned_strings).nTableMask; if (CG(interned_strings).arHash[nIndex] == idx) { |