commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r570232 - /commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/EvalContext.java
Date Mon, 27 Aug 2007 19:49:34 GMT
Author: mbenson
Date: Mon Aug 27 12:49:33 2007
New Revision: 570232

URL: http://svn.apache.org/viewvc?rev=570232&view=rev
Log:
break out pointer sort for reuse, protected; only sort reverse when order = -1

Modified:
    commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/EvalContext.java

Modified: commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/EvalContext.java
URL: http://svn.apache.org/viewvc/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/EvalContext.java?rev=570232&r1=570231&r2=570232&view=diff
==============================================================================
--- commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/EvalContext.java (original)
+++ commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/EvalContext.java Mon
Aug 27 12:49:33 2007
@@ -172,14 +172,25 @@
             return false;
         }
 
-        if (getDocumentOrder() == 1) {
-            Collections.sort(list);
-        }
-        else {
-            Collections.sort(list, ReverseComparator.INSTANCE);
-        }
+        sortPointers(list);
+
         pointerIterator = list.iterator();
         return true;
+    }
+
+    /**
+     * Sort a list of pointers based on document order.
+     * @param l the list to sort.
+     */
+    protected void sortPointers(List l) {
+        switch (getDocumentOrder()) {
+        case 1:
+            Collections.sort(l);
+            break;
+        case -1:
+            Collections.sort(l, ReverseComparator.INSTANCE);
+            break;
+        }
     }
 
     /**



Mime
View raw message