canReadCommit: move check for READ on refs/* on top

This should improve performance for those users who have READ access
on refs/*. Since this check is much cheaper than walking potentially
large commit graphs, move it to the top of the method. Only when user
doesn't have READ on refs/* do the usual reachability check from
all readable branches and tags.

Change-Id: I48341112347c1c4708c4b6b94c3326da6de8d8fb
This commit is contained in:
Sasa Zivkov
2013-11-20 16:11:37 +01:00
parent 7aeed26213
commit d9b18a81d5

View File

@@ -490,6 +490,10 @@ public class ProjectControl {
}
public boolean canReadCommit(RevWalk rw, RevCommit commit) {
if (controlForRef("refs/*").canPerform(Permission.READ)) {
return true;
}
Project.NameKey projName = state.getProject().getNameKey();
try {
Repository repo = repoManager.openRepository(projName);
@@ -521,6 +525,6 @@ public class ProjectControl {
commit.name(), projName.get());
log.error(msg, e);
}
return controlForRef("refs/*").canPerform(Permission.READ);
return false;
}
}