use zend_string_equals_ci

This commit is contained in:
Xinchen Hui 2014-08-29 13:19:14 +08:00
parent 49bd049b7e
commit 0763d6b98d
2 changed files with 6 additions and 10 deletions

View File

@ -3051,14 +3051,11 @@ ZEND_API void zend_initialize_class_data(zend_class_entry *ce, zend_bool nullify
uint32_t zend_get_class_fetch_type(zend_string *name) /* {{{ */
{
if (name->len == sizeof("self") - 1 &&
!strncasecmp(name->val, "self", sizeof("self") - 1)) {
if (zend_string_equals_literal_ci(name, "self")) {
return ZEND_FETCH_CLASS_SELF;
} else if (name->len == sizeof("parent") - 1 &&
!strncasecmp(name->val, "parent", sizeof("parent") - 1)) {
} else if (zend_string_equals_literal_ci(name, "parent")) {
return ZEND_FETCH_CLASS_PARENT;
} else if (name->len == sizeof("static") - 1 &&
!strncasecmp(name->val, "static", sizeof("static") - 1)) {
} else if (zend_string_equals_literal_ci(name, "static")) {
return ZEND_FETCH_CLASS_STATIC;
} else {
return ZEND_FETCH_CLASS_DEFAULT;
@ -3253,10 +3250,6 @@ static inline zend_bool zend_string_equals_str_ci(zend_string *str1, zend_string
}
/* }}} */
#define zend_string_equals_literal_ci(str, c) \
((str)->len == sizeof(c) - 1 \
&& !zend_binary_strcasecmp((str)->val, (str)->len, (c), sizeof(c) - 1))
static void zend_adjust_for_fetch_type(zend_op *opline, uint32_t type) /* {{{ */
{
switch (type & BP_VAR_MASK) {

View File

@ -214,6 +214,9 @@ static zend_always_inline zend_bool zend_string_equals(zend_string *s1, zend_str
return s1 == s2 || (s1->len == s2->len && !memcmp(s1->val, s2->val, s1->len));
}
#define zend_string_equals_literal_ci(str, c) \
((str)->len == sizeof(c) - 1 && !zend_binary_strcasecmp((str)->val, (str)->len, (c), sizeof(c) - 1))
#define zend_string_equals_literal(str, literal) \
((str)->len == sizeof(literal)-1 && !memcmp((str)->val, literal, sizeof(literal) - 1))