IJPL-150081 TimSort thinks HighlightInfoUpdaterImpl.sortByPsiElementFertility is cringe

GitOrigin-RevId: 444db6cf6a5672f3be753c4e06beb9e866fbcb72
This commit is contained in:
Alexey Kudravtsev
2025-10-07 18:28:10 +00:00
committed by intellij-monorepo-bot
parent 83381aa6ac
commit 2bfe62a1fc
@@ -872,11 +872,16 @@ public final class HighlightInfoUpdaterImpl extends HighlightInfoUpdater impleme
(e1, e2) -> {
List<? extends HighlightInfo> infos1 = highlights.get(e1);
List<? extends HighlightInfo> infos2 = highlights.get(e2);
if ((infos1 == null) != (infos2 == null)) {
return infos1 == null ? 1 : -1; // put fertile element first
}
if (infos1 == null) {
return Integer.compare(System.identityHashCode(e1), System.identityHashCode(e2)); // for consistency
if (infos1 == null || infos2 == null) {
if (infos1 != null) { // put fertile element first
return -1;
}
else if (infos2 != null) {
return 1;
}
else {
return Integer.compare(System.identityHashCode(e1), System.identityHashCode(e2)); // for consistency
}
}
// put error-generating element first
return maxSeverity(infos2).compareTo(maxSeverity(infos1));