You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by sc...@apache.org on 2013/11/07 19:39:18 UTC

svn commit: r1539755 - /uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSLeafIndexImpl.java

Author: schor
Date: Thu Nov  7 18:39:18 2013
New Revision: 1539755

URL: http://svn.apache.org/r1539755
Log:
[UIMA-3413] a little probably-mostly-cosmetic rework of the comparator code, probably of no performance consequence.

Modified:
    uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSLeafIndexImpl.java

Modified: uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSLeafIndexImpl.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSLeafIndexImpl.java?rev=1539755&r1=1539754&r2=1539755&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSLeafIndexImpl.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSLeafIndexImpl.java Thu Nov  7 18:39:18 2013
@@ -205,14 +205,10 @@ public abstract class FSLeafIndexImpl<T 
   }
 
   public int compare(int fs1, int fs2) {
-    int[] heap = this.lowLevelCAS.getHeap().heap;
-    int val1, val2;
-    int compVal;
-    float float1, float2;
-    String string1, string2;
+    final int[] heap = this.lowLevelCAS.getHeap().heap;
     for (int i = 0; i < this.numKeys; i++) {
-      val1 = heap[fs1 + this.keyOffset[i]];
-      val2 = heap[fs2 + this.keyOffset[i]];
+      final int val1 = heap[fs1 + this.keyOffset[i]];
+      final int val2 = heap[fs2 + this.keyOffset[i]];
       switch (this.keyType[i]) {
         case STRING_CODE: {
           // System.out.println("Comparing string codes " + val1 + " and "
@@ -228,8 +224,9 @@ public abstract class FSLeafIndexImpl<T 
           // if (lowLevelCAS.getStringForCode(val2) == null) {
           // System.out.println("Value for " + val2 + " is <null>.");
           // }
-          string1 = this.lowLevelCAS.getStringForCode(val1);
-          string2 = this.lowLevelCAS.getStringForCode(val2);
+          final String string1 = this.lowLevelCAS.getStringForCode(val1);
+          final String string2 = this.lowLevelCAS.getStringForCode(val2);
+          int compVal;
           if (string1 == null) {
             if (string2 == null) {
               compVal = 0;
@@ -253,8 +250,8 @@ public abstract class FSLeafIndexImpl<T 
           break;
         }
         case FLOAT_CODE: {
-          float1 = CASImpl.int2float(val1);
-          float2 = CASImpl.int2float(val2);
+          final float float1 = CASImpl.int2float(val1);
+          final float float2 = CASImpl.int2float(val2);
           if (float1 < float2) {
             if (this.keyComp[i] == FSIndexComparator.STANDARD_COMPARE) {
               return -1;
@@ -284,8 +281,8 @@ public abstract class FSLeafIndexImpl<T 
           return -1;
         }
         case LONG_CODE: {
-          long long1 = this.lowLevelCAS.getLongHeap().getHeapValue(val1);
-          long long2 = this.lowLevelCAS.getLongHeap().getHeapValue(val2);
+          final long long1 = this.lowLevelCAS.getLongHeap().getHeapValue(val1);
+          final long long2 = this.lowLevelCAS.getLongHeap().getHeapValue(val2);
           if (long1 < long2) {
             if (this.keyComp[i] == FSIndexComparator.STANDARD_COMPARE) {
               return -1;
@@ -300,8 +297,8 @@ public abstract class FSLeafIndexImpl<T 
           break;
         }
         case DOUBLE_CODE: {
-          double double1 = Double.longBitsToDouble(this.lowLevelCAS.getLongHeap().getHeapValue(val1));
-          double double2 = Double.longBitsToDouble(this.lowLevelCAS.getLongHeap().getHeapValue(val2));
+          final double double1 = Double.longBitsToDouble(this.lowLevelCAS.getLongHeap().getHeapValue(val1));
+          final double double2 = Double.longBitsToDouble(this.lowLevelCAS.getLongHeap().getHeapValue(val2));
           if (double1 < double2) {
             if (this.keyComp[i] == FSIndexComparator.STANDARD_COMPARE) {
               return -1;