From 2bfe62a1fc2479f149c85e77ba6efc2bd77e726c Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Tue, 7 Oct 2025 15:37:49 +0200 Subject: [PATCH] IJPL-150081 TimSort thinks HighlightInfoUpdaterImpl.sortByPsiElementFertility is cringe GitOrigin-RevId: 444db6cf6a5672f3be753c4e06beb9e866fbcb72 --- .../daemon/impl/HighlightInfoUpdaterImpl.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoUpdaterImpl.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoUpdaterImpl.java index c28dcb4dc4e6..2cccf884e3ae 100644 --- a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoUpdaterImpl.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoUpdaterImpl.java @@ -872,11 +872,16 @@ public final class HighlightInfoUpdaterImpl extends HighlightInfoUpdater impleme (e1, e2) -> { List infos1 = highlights.get(e1); List 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));