Prevent getAllPlayersPermissions() processing a group more than once.

Improves performance when using complex inheritance structures.
This commit is contained in:
ElgarL 2012-02-02 18:10:35 +00:00
parent a0103afde3
commit 76ba5caeec
2 changed files with 27 additions and 19 deletions

View file

@ -135,3 +135,4 @@ v 1.9:
- Track the 'onPlayerChangeWorld' event as some teleports seem to not be triggering a world move. - Track the 'onPlayerChangeWorld' event as some teleports seem to not be triggering a world move.
- Catch all errors in badly formatted groups. - Catch all errors in badly formatted groups.
- Fix a bug with getWorldData return the main world data for all mirrors, instead of the worlds parent data. - Fix a bug with getWorldData return the main world data for all mirrors, instead of the worlds parent data.
- Prevent getAllPlayersPermissions() processing a group more than once. Improves performance when using complex inheritance structures.

View file

@ -121,8 +121,14 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
// Add the players own permissions. // Add the players own permissions.
playerPermArray.addAll(populatePerms(ph.getUser(userName).getPermissionList(), includeChildren)); playerPermArray.addAll(populatePerms(ph.getUser(userName).getPermissionList(), includeChildren));
ArrayList<String> alreadyProcessed = new ArrayList<String>();
// fetch all group permissions // fetch all group permissions
for (String group : getGroups(userName)) { for (String group : getGroups(userName)) {
// Don't process a group more than once.
if (!alreadyProcessed.contains(group)) {
alreadyProcessed.add(group);
Set<String> groupPermArray = new HashSet<String>(); Set<String> groupPermArray = new HashSet<String>();
if (group.startsWith("g:") && GroupManager.getGlobalGroups().hasGroup(group)) { if (group.startsWith("g:") && GroupManager.getGlobalGroups().hasGroup(group)) {
@ -143,6 +149,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|| (negated && !playerPermArray.contains(perm.substring(1)))) || (negated && !playerPermArray.contains(perm.substring(1))))
playerPermArray.add(perm); playerPermArray.add(perm);
} }
}
} }
// Collections.sort(playerPermArray, StringPermissionComparator.getInstance()); // Collections.sort(playerPermArray, StringPermissionComparator.getInstance());