Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e9ff062

Browse filesBrowse files
committed
minor #29309 Optimize perf by replacing call_user_func with dynamic variables (ostrolucky)
This PR was merged into the 4.1 branch. Discussion ---------- Optimize perf by replacing call_user_func with dynamic variables | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | This provides similar boost as in symfony/symfony#29245, but on more places and without complexity increase. Check eg. https://github.com/fab2s/call_user_func for proof Fabpot failure unrelated Commits ------- 0c6ef01713 Optimize perf by replacing call_user_func with dynamic vars
2 parents b3987f2 + 2608e73 commit e9ff062
Copy full SHA for e9ff062

File tree

Expand file treeCollapse file tree

3 files changed

+8
-8
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+8
-8
lines changed

‎Tests/Adapter/PhpArrayAdapterTest.php

Copy file name to clipboardExpand all lines: Tests/Adapter/PhpArrayAdapterTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,11 @@ class PhpArrayAdapterWrapper extends PhpArrayAdapter
122122
{
123123
public function save(CacheItemInterface $item)
124124
{
125-
\call_user_func(\Closure::bind(function () use ($item) {
125+
(\Closure::bind(function () use ($item) {
126126
$this->values[$item->getKey()] = $item->get();
127127
$this->warmUp($this->values);
128128
$this->values = eval(substr(file_get_contents($this->file), 6));
129-
}, $this, PhpArrayAdapter::class));
129+
}, $this, PhpArrayAdapter::class))();
130130

131131
return true;
132132
}

‎Tests/CacheItemTest.php

Copy file name to clipboardExpand all lines: Tests/CacheItemTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ public function testTag()
5959
$this->assertSame($item, $item->tag('foo'));
6060
$this->assertSame($item, $item->tag(array('bar', 'baz')));
6161

62-
\call_user_func(\Closure::bind(function () use ($item) {
62+
(\Closure::bind(function () use ($item) {
6363
$this->assertSame(array('foo' => 'foo', 'bar' => 'bar', 'baz' => 'baz'), $item->tags);
64-
}, $this, CacheItem::class));
64+
}, $this, CacheItem::class))();
6565
}
6666

6767
/**

‎Tests/Simple/PhpArrayCacheTest.php

Copy file name to clipboardExpand all lines: Tests/Simple/PhpArrayCacheTest.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,11 @@ class PhpArrayCacheWrapper extends PhpArrayCache
116116
{
117117
public function set($key, $value, $ttl = null)
118118
{
119-
\call_user_func(\Closure::bind(function () use ($key, $value) {
119+
(\Closure::bind(function () use ($key, $value) {
120120
$this->values[$key] = $value;
121121
$this->warmUp($this->values);
122122
$this->values = eval(substr(file_get_contents($this->file), 6));
123-
}, $this, PhpArrayCache::class));
123+
}, $this, PhpArrayCache::class))();
124124

125125
return true;
126126
}
@@ -130,13 +130,13 @@ public function setMultiple($values, $ttl = null)
130130
if (!\is_array($values) && !$values instanceof \Traversable) {
131131
return parent::setMultiple($values, $ttl);
132132
}
133-
\call_user_func(\Closure::bind(function () use ($values) {
133+
(\Closure::bind(function () use ($values) {
134134
foreach ($values as $key => $value) {
135135
$this->values[$key] = $value;
136136
}
137137
$this->warmUp($this->values);
138138
$this->values = eval(substr(file_get_contents($this->file), 6));
139-
}, $this, PhpArrayCache::class));
139+
}, $this, PhpArrayCache::class))();
140140

141141
return true;
142142
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.