phalcon/cphalcon — pull request #948 by sjinks (2013-07-28 17:42:57+00:00)
Title: [NFR] Scope lookup optimizations

`[zend_do_inheritance()](http://lxr.php.net/xref/PHP_5_3/Zend/zend_compile.c#2876)`copies all functions from the parent class function table into the inherited class function table. Therefore, if a parent has implemented a function, it will be present in its child's function table.

As a consequence, we don't have to traverse all zend_class_entries and look for the function: if it is defined by a parent, we will see it in our scope.

Thus, if we don't look up the scope, we
* save a call to zend_str_tolower_dup (and emalloc()/efree())
* possibly save a call to zend_inline_hash_func()
* save a call to phalcon_hash_quick_exists()

For usual method calls and static self:: calls we don't need phalcon_find_scope() at all — `EG(scope) = Z_OBJCE_P(obj)` is sufficient.

For parent calls we only need to check if our class is present in the inheritance of the given `this_ptr`.
It will be faster to compare zend_class_entries than class names though (I will probably address this later).