diff options
author | Dmitry Stogov <dmitry@zend.com> | 2014-12-24 15:04:51 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2014-12-24 15:04:51 +0300 |
commit | c42ac09518d7ec121abb86fc57805e7db56d28ed (patch) | |
tree | 02e4c294ad86c7ad7767d21f2081b165809350fb /Zend/zend_execute_API.c | |
parent | 288b6d78b0ed89216e660bd645c98172d39ba021 (diff) | |
download | php-git-c42ac09518d7ec121abb86fc57805e7db56d28ed.tar.gz |
Added new API function 'zend_string* zend_string_tolower(zend_string*)'.
It simplifies code and avoids unnecessary allocation and copying if string is already in lower case.
Diffstat (limited to 'Zend/zend_execute_API.c')
-rw-r--r-- | Zend/zend_execute_API.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 10238e0396..14be7d4813 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -934,15 +934,14 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, const zval *k lc_name = zend_string_alloc(name->len - 1, 0); zend_str_tolower_copy(lc_name->val, name->val + 1, name->len - 1); } else { - lc_name = zend_string_alloc(name->len, 0); - zend_str_tolower_copy(lc_name->val, name->val, name->len); + lc_name = zend_string_tolower(name); } } ce = zend_hash_find_ptr(EG(class_table), lc_name); if (ce) { if (!key) { - zend_string_free(lc_name); + zend_string_release(lc_name); } return ce; } @@ -952,7 +951,7 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, const zval *k */ if (!use_autoload || zend_is_compiling()) { if (!key) { - zend_string_free(lc_name); + zend_string_release(lc_name); } return NULL; } @@ -963,7 +962,7 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, const zval *k EG(autoload_func) = func; } else { if (!key) { - zend_string_free(lc_name); + zend_string_release(lc_name); } return NULL; } @@ -973,7 +972,7 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, const zval *k /* Verify class name before passing it to __autoload() */ if (strspn(name->val, "0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377\\") != name->len) { if (!key) { - zend_string_free(lc_name); + zend_string_release(lc_name); } return NULL; } @@ -985,7 +984,7 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, const zval *k if (zend_hash_add_empty_element(EG(in_autoload), lc_name) == NULL) { if (!key) { - zend_string_free(lc_name); + zend_string_release(lc_name); } return NULL; } @@ -1029,7 +1028,7 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, const zval *k ce = zend_hash_find_ptr(EG(class_table), lc_name); } if (!key) { - zend_string_free(lc_name); + zend_string_release(lc_name); } return ce; } |