Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

Fix compiler warning and avoid useless assignation to local variable.

Adrien Grandd46e7bbdb5d7
diff --git a/lucene/core/src/java/org/apache/lucene/util/ArrayUtil.java b/lucene/core/src/java/org/apache/lucene/util/ArrayUtil.java
index 1d91c38a023..873426ac011 100644
--- a/lucene/core/src/java/org/apache/lucene/util/ArrayUtil.java
+++ b/lucene/core/src/java/org/apache/lucene/util/ArrayUtil.java
@@ -657,8 +657,7 @@ public final class ArrayUtil {
*/
public static <T extends Comparable<? super T>> void introSort(T[] a, int fromIndex, int toIndex) {
if (toIndex-fromIndex <= 1) return;
- final Comparator<T> comp = naturalComparator();
- introSort(a, fromIndex, toIndex, comp);
+ introSort(a, fromIndex, toIndex, ArrayUtil.<T>naturalComparator());
}
/**
@@ -698,8 +697,7 @@ public final class ArrayUtil {
*/
public static <T extends Comparable<? super T>> void timSort(T[] a, int fromIndex, int toIndex) {
if (toIndex-fromIndex <= 1) return;
- final Comparator<T> comp = naturalComparator();
- timSort(a, fromIndex, toIndex, comp);
+ timSort(a, fromIndex, toIndex, ArrayUtil.<T>naturalComparator());
}
/**
diff --git a/lucene/core/src/java/org/apache/lucene/util/CollectionUtil.java b/lucene/core/src/java/org/apache/lucene/util/CollectionUtil.java
index 65d4b948868..cb23d4524da 100644
--- a/lucene/core/src/java/org/apache/lucene/util/CollectionUtil.java
+++ b/lucene/core/src/java/org/apache/lucene/util/CollectionUtil.java
@@ -17,6 +17,7 @@ package org.apache.lucene.util;
* limitations under the License.
*/
+
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
@@ -145,8 +146,7 @@ public final class CollectionUtil {
public static <T extends Comparable<? super T>> void introSort(List<T> list) {
final int size = list.size();
if (size <= 1) return;
- final Comparator<T> comp = ArrayUtil.naturalComparator();
- introSort(list, comp);
+ introSort(list, ArrayUtil.<T>naturalComparator());
}
// Tim sorts:
@@ -172,8 +172,7 @@ public final class CollectionUtil {
public static <T extends Comparable<? super T>> void timSort(List<T> list) {
final int size = list.size();
if (size <= 1) return;
- final Comparator<T> comp = ArrayUtil.naturalComparator();
- timSort(list, comp);
+ timSort(list, ArrayUtil.<T>naturalComparator());
}
}
diff --git a/lucene/core/src/java/org/apache/lucene/util/Sorter.java b/lucene/core/src/java/org/apache/lucene/util/Sorter.java
index e54615cd1a8..12c53a9b145 100644
--- a/lucene/core/src/java/org/apache/lucene/util/Sorter.java
+++ b/lucene/core/src/java/org/apache/lucene/util/Sorter.java
@@ -187,8 +187,11 @@ public abstract class Sorter {
switch (i - l) {
case 2:
swap(l + 1, l + 2);
+ swap(l, l + 1);
+ break;
case 1:
swap(l, l + 1);
+ break;
case 0:
break;
default: