Skip to content

Commit efce369

Browse files
committed
Directly assign magic methods
Instead of going through intermediary variables.
1 parent 91e5452 commit efce369

File tree

1 file changed

+14
-30
lines changed

1 file changed

+14
-30
lines changed

Zend/zend_API.c

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2147,7 +2147,6 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
21472147
int count=0, unload=0;
21482148
HashTable *target_function_table = function_table;
21492149
int error_type;
2150-
zend_function *ctor = NULL, *dtor = NULL, *clone = NULL, *__get = NULL, *__set = NULL, *__unset = NULL, *__isset = NULL, *__call = NULL, *__callstatic = NULL, *__tostring = NULL, *__debugInfo = NULL, *__serialize = NULL, *__unserialize = NULL;
21512150
zend_string *lowercase_name;
21522151
size_t fname_len;
21532152

@@ -2299,36 +2298,36 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
22992298
if (ZSTR_VAL(lowercase_name)[0] != '_' || ZSTR_VAL(lowercase_name)[1] != '_') {
23002299
reg_function = NULL;
23012300
} else if (zend_string_equals_literal(lowercase_name, ZEND_CONSTRUCTOR_FUNC_NAME)) {
2302-
ctor = reg_function;
2303-
ctor->common.fn_flags |= ZEND_ACC_CTOR;
2301+
scope->constructor = reg_function;
2302+
scope->constructor->common.fn_flags |= ZEND_ACC_CTOR;
23042303
} else if (zend_string_equals_literal(lowercase_name, ZEND_DESTRUCTOR_FUNC_NAME)) {
2305-
dtor = reg_function;
2304+
scope->destructor = reg_function;
23062305
} else if (zend_string_equals_literal(lowercase_name, ZEND_CLONE_FUNC_NAME)) {
2307-
clone = reg_function;
2306+
scope->clone = reg_function;
23082307
} else if (zend_string_equals_literal(lowercase_name, ZEND_CALL_FUNC_NAME)) {
2309-
__call = reg_function;
2308+
scope->__call = reg_function;
23102309
} else if (zend_string_equals_literal(lowercase_name, ZEND_CALLSTATIC_FUNC_NAME)) {
2311-
__callstatic = reg_function;
2310+
scope->__callstatic = reg_function;
23122311
} else if (zend_string_equals_literal(lowercase_name, ZEND_TOSTRING_FUNC_NAME)) {
2313-
__tostring = reg_function;
2312+
scope->__tostring = reg_function;
23142313
} else if (zend_string_equals_literal(lowercase_name, ZEND_GET_FUNC_NAME)) {
2315-
__get = reg_function;
2314+
scope->__get = reg_function;
23162315
scope->ce_flags |= ZEND_ACC_USE_GUARDS;
23172316
} else if (zend_string_equals_literal(lowercase_name, ZEND_SET_FUNC_NAME)) {
2318-
__set = reg_function;
2317+
scope->__set = reg_function;
23192318
scope->ce_flags |= ZEND_ACC_USE_GUARDS;
23202319
} else if (zend_string_equals_literal(lowercase_name, ZEND_UNSET_FUNC_NAME)) {
2321-
__unset = reg_function;
2320+
scope->__unset = reg_function;
23222321
scope->ce_flags |= ZEND_ACC_USE_GUARDS;
23232322
} else if (zend_string_equals_literal(lowercase_name, ZEND_ISSET_FUNC_NAME)) {
2324-
__isset = reg_function;
2323+
scope->__isset = reg_function;
23252324
scope->ce_flags |= ZEND_ACC_USE_GUARDS;
23262325
} else if (zend_string_equals_literal(lowercase_name, ZEND_DEBUGINFO_FUNC_NAME)) {
2327-
__debugInfo = reg_function;
2326+
scope->__debugInfo = reg_function;
23282327
} else if (zend_string_equals_literal(lowercase_name, "__serialize")) {
2329-
__serialize = reg_function;
2328+
scope->__serialize = reg_function;
23302329
} else if (zend_string_equals_literal(lowercase_name, "__unserialize")) {
2331-
__unserialize = reg_function;
2330+
scope->__unserialize = reg_function;
23322331
} else {
23332332
reg_function = NULL;
23342333
}
@@ -2355,21 +2354,6 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
23552354
zend_unregister_functions(functions, count, target_function_table);
23562355
return FAILURE;
23572356
}
2358-
if (scope) {
2359-
scope->constructor = ctor;
2360-
scope->destructor = dtor;
2361-
scope->clone = clone;
2362-
scope->__call = __call;
2363-
scope->__callstatic = __callstatic;
2364-
scope->__tostring = __tostring;
2365-
scope->__get = __get;
2366-
scope->__set = __set;
2367-
scope->__unset = __unset;
2368-
scope->__isset = __isset;
2369-
scope->__debugInfo = __debugInfo;
2370-
scope->__serialize = __serialize;
2371-
scope->__unserialize = __unserialize;
2372-
}
23732357
return SUCCESS;
23742358
}
23752359
/* }}} */

0 commit comments

Comments
 (0)