mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-27 11:43:04 +00:00
Use faster hash algorithm (xxh128) on PHP 8.1
This commit is contained in:
committed by
Jérôme Tamarelle
parent
2117e4b1bc
commit
4fcc6b1c47
+2
-2
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user