lua-users home
lua-l archive

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


You might try building a table mapping bytes to single character strings and
running string.byte through this table. This would essentially optimize
around the more general string interning logic Lua uses.

Mark

on 7/27/04 12:55 PM, Adrian Sietsma at adrian_groups@sietsma.com wrote:

> 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.