Skip to content

Commit

Permalink
Using less expensive equals compare
Browse files Browse the repository at this point in the history
  • Loading branch information
DavyLandman committed Jan 15, 2024
1 parent fdfdbe3 commit 9aa70d3
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -644,9 +644,15 @@ else if (values instanceof Set) {
else {
throw new IllegalArgumentException("Unexpected map entry");
}
// to avoid recalculating `lhs` next time we see it, we mark it as done.
// so that the next time we come across if on the rhs, we know the range is
// already the transitive closure.
// We add it before we've done it, just to avoid scheduling
// <a,a> when it occurs during the depth scan for lhs.
done.add(lhs);
IValue rhs;
while ((rhs = todo.poll()) != null) {
if (rhs.equals(lhs)) {
if (lhs == rhs) {
// no need to handle <a,a>
continue;
}
Expand All @@ -657,10 +663,6 @@ else if (values instanceof Set) {
}
}
}
// `lhs` is now completly calculated, so if we come across it, you don't
// have to go into depth for it anymore, the range of lhs is already the
// transitive closure
done.add(lhs);
}
return result;
}
Expand Down

0 comments on commit 9aa70d3

Please sign in to comment.