-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reuse the immutable empty array in apcu_fetch
Instead of allocating brand new arrays or looking them up in the hash map, return php's shared immutable empty array starting in php 7.3. For #323
- Loading branch information
1 parent
8c05c51
commit 532dd62
Showing
3 changed files
with
68 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--TEST-- | ||
apcu_fetch should work for multiple reference groups | ||
--SKIPIF-- | ||
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> | ||
--INI-- | ||
apc.enabled=1 | ||
apc.enable_cli=1 | ||
--FILE-- | ||
<?php | ||
|
||
$x = []; | ||
$y = []; | ||
$array = [&$x, &$x, &$y, &$y]; | ||
apcu_store("ary", $array); | ||
$copy = apcu_fetch("ary"); | ||
$copy[0][1] = new stdClass(); | ||
var_dump($array); | ||
var_dump($copy); | ||
|
||
?> | ||
--EXPECT-- | ||
array(4) { | ||
[0]=> | ||
&array(0) { | ||
} | ||
[1]=> | ||
&array(0) { | ||
} | ||
[2]=> | ||
&array(0) { | ||
} | ||
[3]=> | ||
&array(0) { | ||
} | ||
} | ||
array(4) { | ||
[0]=> | ||
&array(1) { | ||
[1]=> | ||
object(stdClass)#1 (0) { | ||
} | ||
} | ||
[1]=> | ||
&array(1) { | ||
[1]=> | ||
object(stdClass)#1 (0) { | ||
} | ||
} | ||
[2]=> | ||
&array(0) { | ||
} | ||
[3]=> | ||
&array(0) { | ||
} | ||
} |