Skip to content

Commit

Permalink
Replaced serialize() with json_encode() where appropriate
Browse files Browse the repository at this point in the history
json_encode() is slightly more performant than serialize() on modern PHP. However, unserialize() is measurably faster than json_decode()
  • Loading branch information
JoshyPHP committed Feb 7, 2024
1 parent 267a4be commit 55d800f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Passes/CoalesceSingleCharacterPrefix.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
namespace s9e\RegexpBuilder\Passes;

use function array_merge, array_slice, count, is_int, serialize;
use function array_merge, array_slice, count, is_int, json_encode;
use s9e\RegexpBuilder\Meta;

/**
Expand Down Expand Up @@ -74,7 +74,7 @@ protected function getEligibleKeys(array $strings): array
{
if (is_int($string[0]) && isset($string[1]) && Meta::isChar($string[0]))
{
$suffix = serialize(array_slice($string, 1));
$suffix = json_encode(array_slice($string, 1));
$eligibleKeys[$suffix][] = $k;
}
}
Expand Down

0 comments on commit 55d800f

Please sign in to comment.