[Lxml-checkins] r49912 - in lxml/trunk: . src/lxml

scoder at codespeak.net scoder at codespeak.net
Tue Dec 18 22:29:17 CET 2007


Author: scoder
Date: Tue Dec 18 22:29:16 2007
New Revision: 49912

Modified:
   lxml/trunk/   (props changed)
   lxml/trunk/src/lxml/lxml.etree.pyx
Log:
 r3109 at delle:  sbehnel | 2007-12-18 20:57:43 +0100
 made normal case in index() explicit


Modified: lxml/trunk/src/lxml/lxml.etree.pyx
==============================================================================
--- lxml/trunk/src/lxml/lxml.etree.pyx	(original)
+++ lxml/trunk/src/lxml/lxml.etree.pyx	Tue Dec 18 22:29:16 2007
@@ -934,6 +934,17 @@
         if c_child.parent is not self._c_node:
             raise ValueError, "Element is not a child of this node."
 
+        # handle the unbounded search straight away (normal case)
+        if stop is None and (start is None or start == 0):
+            k = 0
+            c_child = c_child.prev
+            while c_child is not NULL:
+                if _isElement(c_child):
+                    k = k + 1
+                c_child = c_child.prev
+            return k
+
+        # check indices
         if start is None:
             c_start = 0
         else:


More information about the lxml-checkins mailing list