From: Wolfgang M. M. <wol...@us...> - 2005-09-30 14:05:38
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/dom In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23630/src/org/exist/dom Modified Files: ExtArrayNodeSet.java Log Message: Check if nodes are already sorted in document order. Avoid resorting the set. Index: ExtArrayNodeSet.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/ExtArrayNodeSet.java,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** ExtArrayNodeSet.java 24 Sep 2005 10:08:20 -0000 1.27 --- ExtArrayNodeSet.java 30 Sep 2005 14:05:13 -0000 1.28 *************** *** 28,31 **** --- 28,32 ---- import org.exist.util.FastQSort; import org.exist.util.Range; + import org.exist.util.sanity.SanityCheck; import org.exist.xquery.value.Item; import org.exist.xquery.value.SequenceIterator; *************** *** 203,207 **** */ public Iterator iterator() { ! sort(); return new ExtArrayIterator(); } --- 204,209 ---- */ public Iterator iterator() { ! if (!isSorted()) ! sort(); return new ExtArrayIterator(); } *************** *** 223,227 **** */ public SequenceIterator unorderedIterator() { ! sort(); return new ExtArrayIterator(); } --- 225,230 ---- */ public SequenceIterator unorderedIterator() { ! if (!isSorted()) ! sort(); return new ExtArrayIterator(); } *************** *** 270,274 **** */ public int getLength() { ! sort(); // sort to remove duplicates return size; } --- 273,278 ---- */ public int getLength() { ! if (!isSorted()) ! sort(); // sort to remove duplicates return size; } *************** *** 359,362 **** --- 363,370 ---- } + private boolean isSorted() { + return isSorted || isInDocumentOrder; + } + public void sort() { // long start = System.currentTimeMillis(); *************** *** 618,621 **** --- 626,630 ---- else array[i].copyContext(parent); + array[i].addMatches(parent); result.add(array[i], range.getDistance()); break; *************** *** 625,628 **** --- 634,638 ---- else parent.copyContext(array[i]); + parent.addMatches(array[i]); result.add(parent, 1); break; |