diff options
author | Saša Živkov <sasa.zivkov@sap.com> | 2016-11-10 11:19:55 +0100 |
---|---|---|
committer | David Pursehouse <dpursehouse@collab.net> | 2016-11-16 18:16:25 +0000 |
commit | df0145d52fee1ca9e9cf8c95bfc579eb5f33cef2 (patch) | |
tree | 3e71ae93cc56f61658535e5b359d78f5057ecc51 | |
parent | 1d55a32535ee022db2bef36946f88ea174c5c3f2 (diff) |
Avoid unnecessary group visibility checks
The list-groups REST API call checked group visibility even for those
groups which are filtered out. In a system with 10-20K of groups
this can cause 30-60 seconds delay when checking if current user can
see a group.
Avoid unnecessary group visibility checks by moving it towards the end
of the loop. Therefore, group visibility is only checked for those
groups which are not filtered out.
Change-Id: Id5984049d0103fbbf656b704f672f01283844b64
-rw-r--r-- | gerrit-server/src/main/java/com/google/gerrit/server/group/ListGroups.java | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/group/ListGroups.java b/gerrit-server/src/main/java/com/google/gerrit/server/group/ListGroups.java index f3a2ea2b8e..44e8a4dc2f 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/group/ListGroups.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/group/ListGroups.java @@ -322,12 +322,6 @@ public class ListGroups implements RestReadView<TopLevelResource> { continue; } } - if (!isAdmin) { - final GroupControl c = groupControlFactory.controlFor(group); - if (!c.isVisible()) { - continue; - } - } if (visibleToAll && !group.isVisibleToAll()) { continue; } @@ -335,6 +329,12 @@ public class ListGroups implements RestReadView<TopLevelResource> { && !groupsToInspect.contains(group.getGroupUUID())) { continue; } + if (!isAdmin) { + final GroupControl c = groupControlFactory.controlFor(group); + if (!c.isVisible()) { + continue; + } + } filteredGroups.add(group); } Collections.sort(filteredGroups, new GroupComparator()); |