lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpou...@apache.org
Subject svn commit: r1482111 - in /lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util: Sorter.java TimSorter.java
Date Mon, 13 May 2013 21:26:08 GMT
Author: jpountz
Date: Mon May 13 21:26:08 2013
New Revision: 1482111

URL: http://svn.apache.org/r1482111
Log:
LUCENE-4946: Sorter.rotate is a no-op when one of the two adjacent slices to rotate is empty.

Modified:
    lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/Sorter.java
    lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/TimSorter.java

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/Sorter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/Sorter.java?rev=1482111&r1=1482110&r2=1482111&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/Sorter.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/Sorter.java Mon May 13 21:26:08
2013
@@ -72,7 +72,7 @@ public abstract class Sorter {
       first_cut = upper(from, mid, second_cut);
       len11 = first_cut - from;
     }
-    rotate( first_cut, mid, second_cut);
+    rotate(first_cut, mid, second_cut);
     final int new_mid = first_cut + len22;
     mergeInPlace(from, first_cut, new_mid);
     mergeInPlace(new_mid, second_cut, to);
@@ -142,7 +142,15 @@ public abstract class Sorter {
     }
   }
 
-  void rotate(int lo, int mid, int hi) {
+  final void rotate(int lo, int mid, int hi) {
+    assert lo <= mid && mid <= hi;
+    if (lo == mid || mid == hi) {
+      return;
+    }
+    doRotate(lo, mid, hi);
+  }
+
+  void doRotate(int lo, int mid, int hi) {
     if (mid - lo == hi - mid) {
       // happens rarely but saves n/2 swaps
       while (mid < hi) {

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/TimSorter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/TimSorter.java?rev=1482111&r1=1482110&r2=1482111&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/TimSorter.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/TimSorter.java Mon May 13
21:26:08 2013
@@ -205,9 +205,9 @@ public abstract class TimSorter extends 
   }
 
   @Override
-  void rotate(int lo, int mid, int hi) {
-    int len1 = mid - lo;
-    int len2 = hi - mid;
+  void doRotate(int lo, int mid, int hi) {
+    final int len1 = mid - lo;
+    final int len2 = hi - mid;
     if (len1 == len2) {
       while (mid < hi) {
         swap(lo++, mid++);



Mime
View raw message