Skip to content

Commit f38f1f7

Browse files
committedJan 4, 2025·
minor #6682 Minor performance improvement in Twig extension (javiereguiluz)
This PR was merged into the 4.x branch. Discussion ---------- Minor performance improvement in Twig extension `spl_object_id()` is slightly faster than `spl_object_hash()` (see symfony/symfony#59355) and `xxhash` algorithms are much faster than `md5` Commits ------- f595045 Minor performance improvement in Twig extension
2 parents 996be4b + f595045 commit f38f1f7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed
 

‎src/Twig/EasyAdminTwigExtension.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public function representAsString($value, string|callable|null $toStringMethod =
182182
return sprintf('%s #%s', $value::class, $value->getId());
183183
}
184184

185-
return sprintf('%s #%s', $value::class, substr(md5(spl_object_hash($value)), 0, 7));
185+
return sprintf('%s #%s', $value::class, hash('xxh32', (string) spl_object_id($value)));
186186
}
187187

188188
return '';

0 commit comments

Comments
 (0)
Please sign in to comment.