[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Implemented fast string append and a new call a = string.append(a, b)
- From: Norman Ramsey <nr@...>
- Date: Sat, 29 Nov 2008 21:59:52 -0500
> Basically, all programmers expect that a = a .. b should be efficient.
A programmer with a decent education should expect that in a language
with immutable strings, iterated concatenation is quadratic in the
length of the result. A programmer without a decent education will
discover the quadratic behavior when it becomes important in practice.
(No blame attaches to programmers without decent educations, although
some blame might attach to their teachers.)
Your string extension looks entirely worthwhile, but it should be a
new type of userdata from which a Lua string can be extracted once the
concatenation is finished. Unless, of course, somebody can match its
performance using table.concat :-)