Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[HttpKernel] minor optimalization at bundle initialization #9657

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

Closed
wants to merge 1 commit into from
Closed

[HttpKernel] minor optimalization at bundle initialization #9657

wants to merge 1 commit into from

Conversation

tgabi333
Copy link
Contributor

fast check to avoid six array method calls

Q A
Bug fix? [no]
New feature? [no]
BC breaks? [no]
Deprecations? [
Tests pass? [yes]
Fixed tickets
License MIT
Doc PR

fast check to avoid six array method calls
@@ -497,7 +497,7 @@ protected function initializeBundles()
}

// look for orphans
if (count($diff = array_values(array_diff(array_keys($directChildren), array_keys($this->bundles))))) {
if (!empty($directChildren) && count($diff = array_values(array_diff(array_keys($directChildren), array_keys($this->bundles))))) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's even faster like this:

if (!empty($directChildren) && count($diff = array_diff_key($directChildren, $this->bundles))) {
    $diff = array_keys($diff);
    throw new \LogicException(sprintf('Bundle "%s" extends bundle "%s", which is not registered.', $directChildren[$diff[0]], $diff[0]));
}

@fabpot
Copy link
Member

fabpot commented Nov 30, 2013

see #9664

@fabpot fabpot closed this Nov 30, 2013
fabpot added a commit that referenced this pull request Nov 30, 2013
…n (fabpot)

This PR was merged into the 2.2 branch.

Discussion
----------

[HttpKernel] minor optimalization at bundle initialization

fast check to avoid six array method calls

| Q             | A
| ------------- | ---
| Bug fix?      | [no]
| New feature?  | [no]
| BC breaks?    | [no]
| Deprecations? | [|no]
| Tests pass?   | [yes]
| Fixed tickets | #9657
| License       | MIT
| Doc PR        |

That's a rebased version of #9657 on 2.2 + another optimization suggested by @GromNaN

Commits
-------

3330c40 [HttpKernel] made a small optimization to Bundle initialization
4ba6c0b minor optimalization at bundle initialization
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants