Use faster hash algorithm (xxh128) on PHP 8.1

This commit is contained in:
Jérôme TAMARELLE
2021-11-07 00:31:56 +01:00
committed by Jérôme Tamarelle
parent 2117e4b1bc
commit 4fcc6b1c47
7 changed files with 19 additions and 7 deletions
+2 -2
View File
@@ -298,7 +298,7 @@ class Environment
{
$key = $this->getLoader()->getCacheKey($name).$this->optionsHash;
return $this->templateClassPrefix.hash('sha256', $key).(null === $index ? '' : '___'.$index);
return $this->templateClassPrefix.hash(\PHP_VERSION_ID < 80100 ? 'sha256' : 'xxh128', $key).(null === $index ? '' : '___'.$index);
}
/**
@@ -445,7 +445,7 @@ class Environment
*/
public function createTemplate($template, string $name = null)
{
$hash = hash('sha256', $template, false);
$hash = hash(\PHP_VERSION_ID < 80100 ? 'sha256' : 'xxh128', $template, false);
if (null !== $name) {
$name = sprintf('%s (string template %s)', $name, $hash);
} else {