You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feature #61057 [Security] Improve performance of RoleHierarchy::buildRoleMap method (simonjamain-gp, simonjamain)
This PR was squashed before being merged into the 7.4 branch.
Discussion
----------
[Security] Improve performance of `RoleHierarchy::buildRoleMap` method
| Q | A
| ------------- | ---
| Branch? | 7.4
| Bug fix? | no
| New feature? | no (perf)
| Deprecations? | no
| Issues | Fix#57322
| License | MIT
use of an optimized role ustacking function
### What it does and why it's needed
_Note : Better in-detail explanation in there : https://github.com/symfony/symfony/issues/57322_
Uses the way faster `array_pop()` function to build the role map instead of `array shift`
### If it modifies existing behavior, include a before/after comparison
At first, it would look like this function swap could change slightly the ordering of the array produced by the `RoleHierarchy::buildRoleMap` method and it does it in a way. I find that it does not change the behaviour of our app.
I would not expect most other apps too break because I don't find many reasons to rely on the ordering of roles in hierarchies. Furthermore, `buildRoleMap` is a protected method serving the public `getReachableRoleNames` which does not imply a particular ordering (rightfully so IMHO).
### Testing
As it does not change or introduce any behavious per say, this performance increase rely on old tests passing again.
If I am not mistaken, the current `testGetReachableRoleNames()` still passes even tho it asserts a specific ordering. I still changed the assertion so it does not convey any false premises.
Commits
-------
508b62f [Security] Improve performance of `RoleHierarchy::buildRoleMap` method
0 commit comments