canReadCommit: swap preconditions check to improve performance

It is much cheaper to check READ access on a ref than to check
if a commit is merged into that ref. Therefore, do the checks in
this order and avoid traversal of potentially large commit graph
when we know that the user cannot read that branch.

Change-Id: I008990915e15854100a84b3d795f6c54efe35c81
This commit is contained in:
Sasa Zivkov 2013-11-14 15:22:32 +01:00
parent 16da16af68
commit 5cf89bc928

View File

@ -506,8 +506,8 @@ public class ProjectControl {
} catch (IncorrectObjectTypeException e) {
continue;
}
if (rw.isMergedInto(commit, tip)
&& controlForRef(entry.getKey()).canPerform(Permission.READ)) {
if (controlForRef(entry.getKey()).canPerform(Permission.READ)
&& rw.isMergedInto(commit, tip)) {
return true;
}
}