lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Ashwin Hirschi wrote:

As it turns out strsub is about 1.4 times slower than strbyte. I expect Lua5 to give you approximately the same results. But you can easily test this yourself.

i tried it both ways for real in my xml parser :

strsub version : total process time (100 x 29kb) was 5207 ms,
strbyte version : time = 5127 ms.

swings and roundabouts... i think what i gain with strbyte i lose with "if ch == GT " as opposed to "if ch == '>' ". i could probably optimise it further, but i have a c++ version for max speed anyway.

ps -
now that i've ported my parser to lua, does the wiki need yet another xml parser? this one is a sax-type callback parser, which can
1/ parse (but not interpret) embedded DTD's
2/ handle html-type naked and value-less attributes
3/ handle html-type overlapping tags (sort-of)

i ported this because it is block-based, maintaining state between calls, so you can parse an xml stream as a sequence of chunks.
approx 26 kb of source (not production quality, yet)

Adrian