[Mono-bugs] [Bug 50678][Wis] New - XPath: We need to audit perf on Count and Position

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Thu, 6 Nov 2003 23:47:08 -0500 (EST)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by bmaurer@users.sf.net.

http://bugzilla.ximian.com/show_bug.cgi?id=50678

--- shadow/50678	2003-11-06 23:47:08.000000000 -0500
+++ shadow/50678.tmp.3444	2003-11-06 23:47:08.000000000 -0500
@@ -0,0 +1,45 @@
+Bug#: 50678
+Product: Mono/Class Libraries
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: Unknown
+Priority: Wishlist
+Component: System.XML
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: bmaurer@users.sf.net               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Summary: XPath: We need to audit perf on Count and Position
+
+With the new Reverse Axis queries, we can often override the Count method,
+which would save cloning the iterator and looping through it. We should
+also cache the Count value if we ever have to look it up in a forward axis.
+
+As well, we need to optimize queries such as:
+
+blah [last ()]
+
+So that they just do the following:
+XPathNavigator last = null;
+while (child_blah_iterator.MoveNext ())
+   last = child_blah_iterator.Current;
+
+return last;
+
+rather than:
+
+while (child_blah_iterator.MoveNext ()) {
+   XPathNodeIterator c = child_blah_iterator.Clone;
+   int count = pos;
+   while (c.MoveNext ()) {
+       count ++;
+   }
+   if (pos == count)
+       return child_blah_iterator.Current;
+}
+
+The first way runs in O(n) time, while the second runs in O(n^2) time.