-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[11.x] Blade Component Loop Speed Improvement #51158
[11.x] Blade Component Loop Speed Improvement #51158
Conversation
src/Illuminate/View/Factory.php
Outdated
if (isset($this->normalizedNames[$name])) { | ||
return $this->normalizedNames[$name]; | ||
} | ||
|
||
|
||
$this->normalizedNames[$name] = ViewName::normalize($name); | ||
|
||
return $this->normalizedNames[$name]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This syntax should also be possible:
if (isset($this->normalizedNames[$name])) { | |
return $this->normalizedNames[$name]; | |
} | |
$this->normalizedNames[$name] = ViewName::normalize($name); | |
return $this->normalizedNames[$name]; | |
return $this->normalizedNames[$name] ??= ViewName::normalize($name); |
Hi @lonnylot - could you fix the conflicts here? Update: Think I got it. |
003d994
to
be862c7
Compare
Pushed the fix before I saw the update |
👀 Slight mistake in the updated formatting that affects performance. Let me know if you want me to correct it or if you're taking care of it (don't want to cause conflicts) |
@lonnylot you can fix. |
@taylorotwell Actually your update is better and I just adjusted the tests. I can come back later and do additional profiling to confirm the performance improvement still exists. |
@lonnylot in my testing locally the performance improvements are still in place. 👍 For reference, rendering 20,000 components locally takes ~98ms before your change and ~90ms after. Taking average of 10 iterations per benchmark. |
Cache repeated processes that will not change creates a 7% performance improvement:
Before:
After:
Profiling methodology: #51141 (comment)
welcome.blade.php
avatar.blade.php
<div> Hi! My name is {{ $name }} </div>
routes/web.php