ChangeKindCacheImpl: Don't use reference equality for trees
It is basically an implementation detail of the JGit RevWalk machinery that the getTree() methods for two RevCommits from the same RevWalk return the same RevTree instance. Although it may be a documented and stable detail, the code is easier to reason about if we don't depend on it. This particular code is in a cache loader, where we are certainly not sensitive to the performance difference between == and Objects#equals. Change-Id: I7ae66ac80c1344560543692f6631f469f038c979
This commit is contained in:
@@ -316,7 +316,7 @@ public class ChangeKindCacheImpl implements ChangeKindCache {
|
||||
}
|
||||
|
||||
private static boolean isSameDeltaAndTree(RevCommit prior, RevCommit next) {
|
||||
if (next.getTree() != prior.getTree()) {
|
||||
if (!Objects.equals(next.getTree(), prior.getTree())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -329,7 +329,7 @@ public class ChangeKindCacheImpl implements ChangeKindCache {
|
||||
// Make sure that the prior/next delta is the same - not just the tree.
|
||||
// This is done by making sure that the parent trees are equal.
|
||||
for (int i = 0; i < prior.getParentCount(); i++) {
|
||||
if (next.getParent(i).getTree() != prior.getParent(i).getTree()) {
|
||||
if (!Objects.equals(next.getParent(i).getTree(), prior.getParent(i).getTree())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user