Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NFR] Scope lookup optimizations #948

Merged
merged 2 commits into from Jul 28, 2013
Merged

[NFR] Scope lookup optimizations #948

merged 2 commits into from Jul 28, 2013

Conversation

ghost
Copy link

@ghost ghost commented Jul 28, 2013

zend_do_inheritance() 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).

phalcon pushed a commit that referenced this pull request Jul 28, 2013
[NFR] Scope lookup optimizations
@phalcon phalcon merged commit 852ffd9 into phalcon:1.3.0 Jul 28, 2013
@ghost ghost deleted the lookup-scope branch July 28, 2013 20:09
@phalcon
Copy link
Collaborator

phalcon commented Jul 28, 2013

This may break some compatibility with 5.3.0/5.3.1, it seems do_inheritance started working this way since 5.3.3, I think there would not be problem setting 5.3.3 as minimum supported version

@ghost
Copy link
Author

ghost commented Jul 28, 2013

Yes, you are right…

@ghost
Copy link
Author

ghost commented Jul 28, 2013

Actually I can revert the old behavior for 5.3.[012], if necessary

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants