Skip to content

Commit 168376e

Browse files
committed
Cleanup
1 parent 6d88e1c commit 168376e

File tree

1 file changed

+11
-36
lines changed

1 file changed

+11
-36
lines changed

ext/opcache/zend_accelerator_util_funcs.c

Lines changed: 11 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -40,31 +40,6 @@
4040
typedef int (*id_function_t)(void *, void *);
4141
typedef void (*unique_copy_ctor_func_t)(void *pElement);
4242

43-
static void zend_accel_destroy_zend_function(zval *zv)
44-
{
45-
zend_function *function = Z_PTR_P(zv);
46-
47-
if (function->type == ZEND_USER_FUNCTION) {
48-
if (function->op_array.static_variables) {
49-
if (!(GC_FLAGS(function->op_array.static_variables) & IS_ARRAY_IMMUTABLE)) {
50-
if (GC_DELREF(function->op_array.static_variables) == 0) {
51-
FREE_HASHTABLE(function->op_array.static_variables);
52-
}
53-
}
54-
function->op_array.static_variables = NULL;
55-
}
56-
}
57-
58-
zend_function_dtor(zv);
59-
}
60-
61-
static void zend_accel_destroy_zend_class(zval *zv)
62-
{
63-
zend_class_entry *ce = Z_PTR_P(zv);
64-
ce->function_table.pDestructor = zend_accel_destroy_zend_function;
65-
destroy_zend_class(zv);
66-
}
67-
6843
zend_persistent_script* create_persistent_script(void)
6944
{
7045
zend_persistent_script *persistent_script = (zend_persistent_script *) emalloc(sizeof(zend_persistent_script));
@@ -82,10 +57,7 @@ zend_persistent_script* create_persistent_script(void)
8257

8358
void free_persistent_script(zend_persistent_script *persistent_script, int destroy_elements)
8459
{
85-
if (destroy_elements) {
86-
persistent_script->script.function_table.pDestructor = zend_accel_destroy_zend_function;
87-
persistent_script->script.class_table.pDestructor = zend_accel_destroy_zend_class;
88-
} else {
60+
if (!destroy_elements) {
8961
persistent_script->script.function_table.pDestructor = NULL;
9062
persistent_script->script.class_table.pDestructor = NULL;
9163
}
@@ -100,18 +72,21 @@ void free_persistent_script(zend_persistent_script *persistent_script, int destr
10072
efree(persistent_script);
10173
}
10274

103-
static int is_not_internal_function(zval *zv)
104-
{
105-
zend_function *function = Z_PTR_P(zv);
106-
return(function->type != ZEND_INTERNAL_FUNCTION);
107-
}
108-
10975
void zend_accel_free_user_functions(HashTable *ht)
11076
{
77+
Bucket *p;
11178
dtor_func_t orig_dtor = ht->pDestructor;
11279

11380
ht->pDestructor = NULL;
114-
zend_hash_apply(ht, (apply_func_t) is_not_internal_function);
81+
ZEND_HASH_REVERSE_FOREACH_BUCKET(ht, p) {
82+
zend_function *function = Z_PTR(p->val);
83+
84+
if (EXPECTED(function->type == ZEND_USER_FUNCTION)) {
85+
zend_hash_del_bucket(ht, p);
86+
} else {
87+
break;
88+
}
89+
} ZEND_HASH_FOREACH_END();
11590
ht->pDestructor = orig_dtor;
11691
}
11792

0 commit comments

Comments
 (0)