Added query micro-optimization #209

Merged
merged 1 commit into from May 1, 2013

Conversation

Projects
None yet
4 participants
Contributor

dlsniper commented Sep 30, 2012

This adds a micro-optimization to the query and also exposes better the function calls to the profilers like XDebug or XHProf.

Hello,

thank you for positing this Pull Request. I have automatically opened an issue on our Jira Bug Tracker for you with the details of this Pull-Request. See the Link:

http://doctrine-project.org/jira/browse/DBAL-356

lib/Doctrine/DBAL/Connection.php
@@ -739,7 +739,15 @@ public function query()
}
try {
- $statement = call_user_func_array(array($this->_conn, 'query'), $args);
+ switch(func_num_args()) {
+ case 1: $statement = $this->_conn->query($args[0]); break;
@stof

stof Oct 1, 2012

Member

Please fix the formatting:

switch (func_num_args()) {
    case 0:
        $statement = $this->_conn->query();
        break;
    case 1:
        $statement = $this->_conn->query($args[0]);
        break;
}
@stof

stof Oct 1, 2012

Member

btw, I think you can remove the case for 0 as it should never happen.

Owner

beberlei commented Oct 5, 2012

What does this help with xhprof? cant you see the query + args in the parent call?

Contributor

dlsniper commented Oct 7, 2012

@beberlei while you can see them in the parent function this is just a bonus over the micro-optimization benefits from changing the call from call_user_func_array() to direct call type like this.

beberlei added a commit that referenced this pull request May 1, 2013

@beberlei beberlei merged commit 1d8d6bc into doctrine:master May 1, 2013

1 check passed

default The Travis build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment