Skip to content

Commit 1e968f4

Browse files
committed
Zend: Refactor deduplicate auto-global checks
1 parent 7b78eb4 commit 1e968f4

1 file changed

Lines changed: 14 additions & 17 deletions

File tree

Zend/zend_compile.c

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1995,30 +1995,27 @@ static void zend_do_extended_fcall_end(void) /* {{{ */
19951995
}
19961996
/* }}} */
19971997

1998-
ZEND_API bool zend_is_auto_global_str(const char *name, size_t len) /* {{{ */ {
1999-
zend_auto_global *auto_global;
1998+
static zend_always_inline bool zend_auto_global_check(zend_auto_global *auto_global)
1999+
{
2000+
if (auto_global == NULL) {
2001+
return false;
2002+
}
20002003

2001-
if ((auto_global = zend_hash_str_find_ptr(CG(auto_globals), name, len)) != NULL) {
2002-
if (auto_global->armed) {
2003-
auto_global->armed = auto_global->auto_global_callback(auto_global->name);
2004-
}
2005-
return 1;
2004+
if (auto_global->armed) {
2005+
auto_global->armed = auto_global->auto_global_callback(auto_global->name);
20062006
}
2007-
return 0;
2007+
return true;
2008+
}
2009+
2010+
ZEND_API bool zend_is_auto_global_str(const char *name, size_t len) /* {{{ */
2011+
{
2012+
return zend_auto_global_check(zend_hash_str_find_ptr(CG(auto_globals), name, len));
20082013
}
20092014
/* }}} */
20102015

20112016
ZEND_API bool zend_is_auto_global(zend_string *name) /* {{{ */
20122017
{
2013-
zend_auto_global *auto_global;
2014-
2015-
if ((auto_global = zend_hash_find_ptr(CG(auto_globals), name)) != NULL) {
2016-
if (auto_global->armed) {
2017-
auto_global->armed = auto_global->auto_global_callback(auto_global->name);
2018-
}
2019-
return 1;
2020-
}
2021-
return 0;
2018+
return zend_auto_global_check(zend_hash_find_ptr(CG(auto_globals), name));
20222019
}
20232020
/* }}} */
20242021

0 commit comments

Comments
 (0)