[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Convert bytes array to string
- From: Eric Tetz <erictetz@...>
- Date: Sat, 16 Mar 2002 12:42:19 -0800 (PST)
--- SATO Seichi <seichi@air.ne.jp> wrote:
> Eric, thank you for your reply.
> But your gsub approach is slower than concatenation.
>
> this is I wrote:
>
> function bytetostring (bytes)
> local buf = strrep(' ', getn(bytes))
> local index = {n = 0}
> local rep = function (c)
> %index.n = %index.n + 1
> return strchar(%bytes[%index.n])
> end
> return gsub(buf, '(.)', rep)
> end
Well, in Lua 4.1w4 it's nearly 10 times faster than concatenation.
I'm surpised it's so much slower in Lua 4.
Cheers,
Eric
__________________________________________________
Do You Yahoo!?
Yahoo! Sports - live college hoops coverage
http://sports.yahoo.com/