10000 minor #19868 [Security] Optimize RoleHierarchy's buildRoleMap method … · symfony/symfony@a630f14 · GitHub
[go: up one dir, main page]

Skip to content

Commit a630f14

Browse files
committed
minor #19868 [Security] Optimize RoleHierarchy's buildRoleMap method (Enleur)
This PR was squashed before being merged into the 2.7 branch (closes #19868). Discussion ---------- [Security] Optimize RoleHierarchy's buildRoleMap method | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | no | License | MIT | Doc PR | no I have an issue with a large role hierarchy(~150 roles). Optimized it a little bit ![image](https://cloud.githubusercontent.com/assets/858989/18271257/df6c4ba0-7439-11e6-8406-e13bdcefe9ca.png) Commits ------- c3b68b0 [Security] Optimize RoleHierarchy's buildRoleMap method
2 parents 993b405 + c3b68b0 commit a630f14

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Symfony/Component/Security/Core/Role/RoleHierarchy.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,17 @@ protected function buildRoleMap()
6565
}
6666

6767
$visited[] = $role;
68-
$this->map[$main] = array_unique(array_merge($this->map[$main], $this->hierarchy[$role]));
69-
$additionalRoles = array_merge($additionalRoles, array_diff($this->hierarchy[$role], $visited));
68+
69+
foreach ($this->hierarchy[$role] as $roleToAdd) {
70+
$this->map[$main][] = $roleToAdd;
71+
}
72+
73+
foreach (array_diff($this->hierarchy[$role], $visited) as $additionalRole) {
74+
$additionalRoles[] = $additionalRole;
75+
}
7076
}
77+
78+
$this->map[$main] = array_unique($this->map[$main]);
7179
}
7280
}
7381
}

0 commit comments

Comments
 (0)
0