On Sep 6, 12:06 pm, "Ville M. Vainio" <[email protected]> wrote:
> I think it would be a better idea to bypass positions for this
> generator, because we can implement *much* more efficient generators
> by using nodes alone.
Rather than calling p.threadNext, c.allNodes_iter could be defined
using:
def threadNext_iter(p):
if p:
p = p.copy() # The only copy
while p:
yield p
if p.hasChildren():
p.moveToFirstChild()
elif p.hasNext():
p.moveToNext()
else:
while p:
p.moveToParent()
if p and p.hasNext():
p.moveToNext()
break
raise StopIteration
The parallel with p.moveToThreadNext is exact. Clearly,
p.moveToFirstChild, p.moveToNext and p.moveToParent are very fast, so
it seems that this is about as good as can be expected. But this code
is so much cleaner than the present code.
Anyway, it is quite fun to play with various ideas. It's all good, as
long as we can drop in new versions for old versions without changing
Leo's core.
Edward
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/leo-editor?hl=en
-~----------~----~----~----~------~----~------~--~---