LUCENE-7751: Avoid boxing primitives only to call compareTo.

This commit is contained in:
Adrien Grand 2017-03-28 15:21:35 +02:00 committed by Shalin Shekhar Mangar
parent a0711a37e5
commit 12d8de86f1
5 changed files with 9 additions and 7 deletions

View File

@ -87,6 +87,9 @@ Other
* LUCENE-7754: Inner classes should be static whenever possible.
(Daniel Jelinski via Adrien Grand)
* LUCENE-7751: Avoid boxing primitives only to call compareTo.
(Daniel Jelinski via Adrien Grand)
======================= Lucene 6.5.0 =======================
API Changes

View File

@ -143,7 +143,7 @@ public final class VirtualMethod<C> {
public static <C> int compareImplementationDistance(final Class<? extends C> clazz,
final VirtualMethod<C> m1, final VirtualMethod<C> m2)
{
return Integer.valueOf(m1.getImplementationDistance(clazz)).compareTo(m2.getImplementationDistance(clazz));
return Integer.compare(m1.getImplementationDistance(clazz), m2.getImplementationDistance(clazz));
}
}

View File

@ -26,7 +26,7 @@ public class SpellCheckCollation implements Comparable<SpellCheckCollation> {
@Override
public int compareTo(SpellCheckCollation scc) {
int c = new Integer(internalRank).compareTo(scc.internalRank);
int c = Integer.compare(internalRank, scc.internalRank);
if (c == 0) {
return collationQuery.compareTo(scc.collationQuery);
}

View File

@ -1636,8 +1636,7 @@ public class DistributedFacetPivotSmallTest extends BaseDistributedSearchTestCas
@Override
public int compare(PivotField o1, PivotField o2) {
Integer compare = (Integer.valueOf(o2.getCount())).compareTo(Integer
.valueOf(o1.getCount()));
int compare = Integer.compare(o2.getCount(), o1.getCount());
if (compare == 0) {
compare = ((String) o2.getValue()).compareTo((String) o1.getValue());
}
@ -1650,7 +1649,7 @@ public class DistributedFacetPivotSmallTest extends BaseDistributedSearchTestCas
}
}
if (compare == 0) {
compare = Integer.valueOf(o1.getFacetQuery().size()).compareTo(
compare = Integer.compare(o1.getFacetQuery().size(),
o2.getFacetQuery().size());
}
}

View File

@ -134,8 +134,8 @@ public abstract class DocRouter {
@Override
public int compareTo(Range that) {
int mincomp = Integer.valueOf(this.min).compareTo(that.min);
return mincomp == 0 ? Integer.valueOf(this.max).compareTo(that.max) : mincomp;
int mincomp = Integer.compare(this.min, that.min);
return mincomp == 0 ? Integer.compare(this.max, that.max) : mincomp;
}
}