Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid String concatenation in compareTo #645

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
if (this == that) {
return 0;
}
int r = this.getFullName().compareTo(that.getFullName());
if (r != 0) {
return r;
int r1 = this.className.compareTo(that.className);
timja marked this conversation as resolved.
Show resolved Hide resolved
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