in reply to Re: Fast enough yet?
in thread Fast enough yet?

A state machine that does it all in one pass has been my holy grail for like 4 years now. Btw.. when I say I've been working on it for 4 years that's not like 4 years of sustained effort or anything, it's a good coding session every now and then interspersed with a lot of other things!

Surely this  $aXML =~ s@;([^:;]+?):@\[$1\(@gs; is the only backtracker there, and also it comes prior to the "save this to disc then process" marker so it only gets run once when the page is still in it's raw aXML state, not every time the page is requested.

That leaves this while ($aXML =~ m@\[([^\[\]]*?)\]@gs) { ... }

Which makes as many passes as it needs to decode the structure, in what I visualise as a sort of 3d way with the innermost tags being the highest peaks getting mown down one tag height at a time, until the document is flat.

Hrm, maybe I could save the $level data into an array to determine character positions for processing... that would help!

Replies are listed 'Best First'.
Re^3: Fast enough yet?
by chromatic (Archbishop) on Aug 08, 2011 at 10:42 UTC

    You wouldn't have to scan the entire structure for every invocation if you returned ASTs from extensions rather than strings that needed parsing, or if you parsed the strings returned from extensions into their own trees and grafted them into the tree.

    Last time, I promise—the first chapter or so of SICP explains evaluation order concerns. It would really help you to read it.

      Chromatic, I want you to know that your responses have been among those I have most valued and enjoyed reading. And I'm not just saying that because I know who you are, I mean it, you and Boldra + a couple of others have taught me huge amounts in a very short time, and I don't believe I ever even caught a hint of condescension in the words coming from your direction. So I just wanted to say that and thanks.