From 03d9d8acf1fbc5aceb1a7e49f19e8e001399e54e Mon Sep 17 00:00:00 2001 From: Alexander Gunnarsson <89029311+AlexanderGunnarssonMW@users.noreply.github.com> Date: Tue, 10 Sep 2024 18:04:55 +0200 Subject: [PATCH] Avoid String concatenation in compareTo (#645) --- src/main/java/hudson/tasks/junit/CaseResult.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/hudson/tasks/junit/CaseResult.java b/src/main/java/hudson/tasks/junit/CaseResult.java index 9ecfeeb3..0010c22b 100644 --- a/src/main/java/hudson/tasks/junit/CaseResult.java +++ b/src/main/java/hudson/tasks/junit/CaseResult.java @@ -955,9 +955,13 @@ public int compareTo(CaseResult that) { if (this == that) { return 0; } - int r = this.getFullName().compareTo(that.getFullName()); - if (r != 0) { - return r; + int r1 = this.className.compareTo(that.className); + if (r1 != 0) { + return r1; + } + int r2 = this.getName().compareTo(that.getName()); + if (r2 != 0) { + return r2; } // Only equals is exact reference return System.identityHashCode(this) >= System.identityHashCode(that) ? 1 : -1;