[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: table.concat - why so complex?
- From: "Martijn van Buul (Ellips B.V.)" <martijn.van.buul@...>
- Date: Tue, 6 Apr 2010 15:10:40 +0200
012345678901234567890123456789012345678901234567890123456789012345678901
23456789
* Peter Hickman
> The reason is to cut down on the number of strlen / strcpy
> operations required at the C level. Just a trade off of memory
> for performance.
This is untrue. First of all, there is no strlen() involved;
all string lengths are known in advance (it's kept in the
len-field of the TValue object representing the string) and the amount
of memcpy()'s can only be HIGHER, since intermediate copies are being
made which could have been prevented.
Note that I wasn't suggesting something like
local result = ""
for _, str in ipairs(sourceArray) do
result = result .. str
end
Instead, I was suggesting something that can't be implemented in lua
directly - but table.concat is implemented in C as it is.