com php-src: Use new hash iteration API.: Zend/zend_hash.h ext/opcache/zend_accelerator_util_funcs.c
| From: | Dmitry Stogov | Date: | Mon, 27 Apr 2015 13:50:47 +0000 |
| Subject: | com php-src: Use new hash iteration API.: Zend/zend_hash.h ext/opcache/zend_accelerator_util_funcs.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-86491@lists.php.net to get a copy of this message | ||
Commit: ffe804a50c687673e2c46a0d4a43ab5eb3604281
Author: Dmitry Stogov <dmitry@zend.com> Mon, 27 Apr 2015 16:50:47 +0300
Parents: 0182eb4717a48ef0768bed9980f92b5be3062ab1
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ffe804a50c687673e2c46a0d4a43ab5eb3604281
Log:
Use new hash iteration API.
Changed paths:
M Zend/zend_hash.h
M ext/opcache/zend_accelerator_util_funcs.c
Diff:
diff --git a/Zend/zend_hash.h b/Zend/zend_hash.h
index 2687ce2..dcac9c3 100644
--- a/Zend/zend_hash.h
+++ b/Zend/zend_hash.h
@@ -814,6 +814,10 @@ static zend_always_inline void *zend_hash_get_current_data_ptr_ex(HashTable
*ht,
_key = _p->key; \
_ptr = Z_PTR_P(_z);
+#define ZEND_HASH_REVERSE_FOREACH_BUCKET(ht, _bucket) \
+ ZEND_HASH_REVERSE_FOREACH(ht, 0); \
+ _bucket = _p;
+
#define ZEND_HASH_REVERSE_FOREACH_VAL(ht, _val) \
ZEND_HASH_REVERSE_FOREACH(ht, 0); \
_val = _z;
diff --git a/ext/opcache/zend_accelerator_util_funcs.c b/ext/opcache/zend_accelerator_util_funcs.c
index 9aefa51...92ada0b 100644
--- a/ext/opcache/zend_accelerator_util_funcs.c
+++ b/ext/opcache/zend_accelerator_util_funcs.c
@@ -118,26 +118,22 @@ void zend_accel_free_user_functions(HashTable *ht)
ht->pDestructor = orig_dtor;
}
-static int move_user_function(zval *zv, int num_args, va_list args, zend_hash_key *hash_key)
-{
- zend_function *function = Z_PTR_P(zv);
- HashTable *function_table = va_arg(args, HashTable *);
- (void)num_args; /* keep the compiler happy */
-
- if (function->type == ZEND_USER_FUNCTION) {
- zend_hash_update_ptr(function_table, hash_key->key, function);
- return 1;
- } else {
- return 0;
- }
-}
-
void zend_accel_move_user_functions(HashTable *src, HashTable *dst)
{
+ Bucket *p;
dtor_func_t orig_dtor = src->pDestructor;
src->pDestructor = NULL;
- zend_hash_apply_with_arguments(src, (apply_func_args_t)move_user_function, 1, dst);
+ ZEND_HASH_REVERSE_FOREACH_BUCKET(src, p) {
+ zend_function *function = Z_PTR(p->val);
+
+ if (EXPECTED(function->type == ZEND_USER_FUNCTION)) {
+ zend_hash_add_new_ptr(dst, p->key, function);
+ zend_hash_del_bucket(src, p);
+ } else {
+ break;
+ }
+ } ZEND_HASH_FOREACH_END();
src->pDestructor = orig_dtor;
}