Cache DefaultRefFilter to speed up subsequent filter() calls

DefaultRefFilter has a Map of visible changes as internal state. Reusing
this map in subsequent calls speeds the operation up.

Change-Id: Idb8627138badfeb3182b5904c3d569789334366c
This commit is contained in:
Patrick Hiesel
2018-02-14 16:49:33 +01:00
parent 3ee59ad132
commit f6fd2307bd

View File

@@ -317,6 +317,7 @@ class ProjectControl {
}
private class ForProjectImpl extends ForProject {
private DefaultRefFilter refFilter;
private String resourcePath;
@Override
@@ -389,7 +390,10 @@ class ProjectControl {
@Override
public Map<String, Ref> filter(Map<String, Ref> refs, Repository repo, RefFilterOptions opts)
throws PermissionBackendException {
return refFilterFactory.create(ProjectControl.this).filter(refs, repo, opts);
if (refFilter == null) {
refFilter = refFilterFactory.create(ProjectControl.this);
}
return refFilter.filter(refs, repo, opts);
}
private boolean can(ProjectPermission perm) throws PermissionBackendException {