Skip to content

Commit

Permalink
Avoid String concatenation in compareTo (#645)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderGunnarssonMW authored Sep 10, 2024
1 parent 8d143ac commit 03d9d8a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/main/java/hudson/tasks/junit/CaseResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Check warning on line 959 in src/main/java/hudson/tasks/junit/CaseResult.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 959 is only partially covered, one branch is missing
return r1;

Check warning on line 960 in src/main/java/hudson/tasks/junit/CaseResult.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 960 is not covered by tests
}
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;
Expand Down

0 comments on commit 03d9d8a

Please sign in to comment.