DefaultRefFilter: Avoid Repository#getAllRefs
Change-Id: I4817ffd75e7d3ec05ced085f10c0d4ef8f8816b2
This commit is contained in:
@@ -20,6 +20,7 @@ import static com.google.gerrit.reviewdb.client.RefNames.REFS_CHANGES;
|
|||||||
import static com.google.gerrit.reviewdb.client.RefNames.REFS_CONFIG;
|
import static com.google.gerrit.reviewdb.client.RefNames.REFS_CONFIG;
|
||||||
import static com.google.gerrit.reviewdb.client.RefNames.REFS_USERS_SELF;
|
import static com.google.gerrit.reviewdb.client.RefNames.REFS_USERS_SELF;
|
||||||
import static java.util.Objects.requireNonNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
import static java.util.stream.Collectors.toMap;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
@@ -248,7 +249,7 @@ class DefaultRefFilter {
|
|||||||
repo,
|
repo,
|
||||||
opts.filterTagsSeparately()
|
opts.filterTagsSeparately()
|
||||||
? filter(
|
? filter(
|
||||||
repo.getAllRefs(),
|
getAllRefsMap(repo),
|
||||||
repo,
|
repo,
|
||||||
opts.toBuilder().setFilterTagsSeparately(false).build())
|
opts.toBuilder().setFilterTagsSeparately(false).build())
|
||||||
.values()
|
.values()
|
||||||
@@ -263,6 +264,14 @@ class DefaultRefFilter {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Map<String, Ref> getAllRefsMap(Repository repo) throws PermissionBackendException {
|
||||||
|
try {
|
||||||
|
return repo.getRefDatabase().getRefs().stream().collect(toMap(Ref::getName, r -> r));
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new PermissionBackendException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Map<String, Ref> fastHideRefsMetaConfig(Map<String, Ref> refs)
|
private Map<String, Ref> fastHideRefsMetaConfig(Map<String, Ref> refs)
|
||||||
throws PermissionBackendException {
|
throws PermissionBackendException {
|
||||||
if (refs.containsKey(REFS_CONFIG) && !canReadRef(REFS_CONFIG)) {
|
if (refs.containsKey(REFS_CONFIG) && !canReadRef(REFS_CONFIG)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user