Skip to content

Commit

Permalink
Avoided self loop in case there is already an self edge to begin with
Browse files Browse the repository at this point in the history
  • Loading branch information
DavyLandman committed Jan 15, 2024
1 parent d0ec41b commit b5cb85b
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -644,18 +644,23 @@ else if (values instanceof Set) {
else {
throw new IllegalArgumentException("Unexpected map entry");
}
// we mark ourselves as done before we did it,
// so we don't do the <a,a> that causes an extra round
done.add(lhs);
IValue rhs;
while ((rhs = todo.poll()) != null) {
if (rhs.equals(lhs)) {
// no need to handle <a,a>
continue;
}
boolean rhsDone = done.contains(rhs);
for (IValue composed : result.get(rhs)) {
if (result.__insert(lhs, composed) && !rhsDone) {
todo.push(composed);
}
}
}
// `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 b5cb85b

Please sign in to comment.