Skip to content

Commit

Permalink
minor #6682 Minor performance improvement in Twig extension (javiereg…
Browse files Browse the repository at this point in the history
…uiluz)

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
  • Loading branch information
javiereguiluz committed Jan 4, 2025
2 parents 996be4b + f595045 commit f38f1f7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Twig/EasyAdminTwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public function representAsString($value, string|callable|null $toStringMethod =
return sprintf('%s #%s', $value::class, $value->getId());
}

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

return '';
Expand Down

0 comments on commit f38f1f7

Please sign in to comment.