Commit 44f6c85
committed
feature symfony#61057 [Security] Improve performance of
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 symfony#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` methodRoleHierarchy::buildRoleMap method (simonjamain-gp, simonjamain)File tree
2 files changed
+7
-7
lines changed- src/Symfony/Component/Security/Core
- Role
- Tests/Role
2 files changed
+7
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| |||
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
0 commit comments