lua-users home
lua-l archive

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


I just wonder, if there wouldn't be concepts more powerful, but not
more complicated than this, that would fully entail this kind of
micro-optimization. Haven't posted it yet, since I always wanted to
get a prototype first and feared knee-jerk-reactions without, but
since its now on topic...

Why not, and this if fully internal to the core, introduce the
Stringbuffer data type? Wait! Before you knee jerk, I'm not talking
about exposing it like Java does. I mean fully opaque in the Lua VM!
For the user strings are immutables like ever, and those who know my
postings as advocate of immutable datastructures should know, I
wouldn't suggest it, as long it would hinder in anyway a roadmap
towards more immutables.

We all like to write str1..str2..str3..str4 and so an. And usually one
of the optimizations we do later on, or suggest people who complain
about performance is to change it to {str1, str2, str3, str4 }.join();
 But how about when concating two strings the Lua VM stores a datatype
that just says "this is str1 joined with str2". Only whenever you do
an operation that cannot be used on this string of strings, like using
it as a table key, it is joined and interned.

As far as I see this kind of optimization concept would fully entail
this experimental feature optimization about uninterning "long
computed strings" , but in the Lua-spirit be a just as small, but more
powerfull concept.

On Wed, Mar 21, 2012 at 7:37 PM, Luiz Henrique de Figueiredo
<lhf@tecgraf.puc-rio.br> wrote:
> Lua 5.2.1 (work1) is now available at
>        http://www.lua.org/work/lua-5.2.1-work1.tar.gz
>
> MD5     bc6b953ee54b7af31f4bc1f2df05fe8f  -
> SHA1    6d9c63f615d2e03b3565e0064599d24aaac49096  -
>
> Lua 5.2.1 introduces better handling of string collisions based on a
> random seed. This work version is meant to let the community assess
> the usefulness and the effectiveness of this experimental feature.
>
> The complete diffs from Lua 5.2.0 to 5.2.1 are available at
>        http://www.lua.org/work/diffs-lua-5.2.0-lua-5.2.1-work1.txt
>
> We thank everyone for their feedback on Lua 5.2 till now.
>
> All feedback welcome. Thanks.
> --lhf