Skip to content

Commit 1eac07f

Browse files
committed
Followup to 1.5 compat changes
1 parent 3dc58af commit 1eac07f

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

tls/src/main/java/org/bouncycastle/jsse/provider/ProvX509KeyManager.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -880,16 +880,18 @@ private static final class Match
880880

881881
public int compareTo(Match that)
882882
{
883-
int cmp = Boolean.compare(that.isValid(), this.isValid());
884-
if (cmp == 0)
883+
boolean thisValid = this.isValid(), thatValid = that.isValid();
884+
if (thisValid != thatValid)
885885
{
886-
cmp = Integer.compare(this.keyTypeIndex, that.keyTypeIndex);
887-
if (cmp == 0)
888-
{
889-
cmp = this.quality.compareTo(that.quality);
890-
}
886+
return thisValid ? -1 : 1;
887+
}
888+
889+
if (this.keyTypeIndex != that.keyTypeIndex)
890+
{
891+
return this.keyTypeIndex < that.keyTypeIndex ? -1 : 1;
891892
}
892-
return cmp;
893+
894+
return this.quality.compareTo(that.quality);
893895
}
894896

895897
boolean isIdeal()

tls/src/main/java/org/bouncycastle/jsse/provider/ProvX509KeyManagerSimple.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -362,16 +362,18 @@ private static final class Match
362362

363363
public int compareTo(Match that)
364364
{
365-
int cmp = (that.isValid() == this.isValid()) ? 0 : (that.isValid() ? 1 : -1);
366-
if (cmp == 0)
365+
boolean thisValid = this.isValid(), thatValid = that.isValid();
366+
if (thisValid != thatValid)
367367
{
368-
cmp = this.keyTypeIndex < that.keyTypeIndex ? -1 : (this.keyTypeIndex == that.keyTypeIndex ? 0 : 1);
369-
if (cmp == 0)
370-
{
371-
cmp = this.quality.compareTo(that.quality);
372-
}
368+
return thisValid ? -1 : 1;
369+
}
370+
371+
if (this.keyTypeIndex != that.keyTypeIndex)
372+
{
373+
return this.keyTypeIndex < that.keyTypeIndex ? -1 : 1;
373374
}
374-
return cmp;
375+
376+
return this.quality.compareTo(that.quality);
375377
}
376378

377379
boolean isIdeal()

0 commit comments

Comments
 (0)