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:
		@@ -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;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user