Hello,

I was surprised to find out that equality checks on zend_string do not take 
advantage of the fact that in many cases we have a hash key available that can 
be utilized in a quick bailout path without having to resort to a costly 
`memcmp` on the value.

I recommend to modify `zend_string_equal_content` like so:

static zend_always_inline zend_bool zend_string_equal_content(zend_string *s1, 
zend_string *s2)
{
  if (ZSTR_LEN(s1) != ZSTR_LEN(s2)) {
    return 0;
  }

  if (ZSTR_H(s1) && ZSTR_H(s1) != ZSTR_H(s2)) {
    return 0;
  }

  return zend_string_equal_val(s1, s2);
}

Thoughts?

-- 

Benjamin Coutu
ben.co...@zeyos.com

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to