[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How to clone a table in LJ2-friendly way?
- From: Alexander Gladysh <agladysh@...>
- Date: Wed, 31 Aug 2011 09:49:03 +0400
On Wed, Aug 31, 2011 at 00:20, Geoff Leyland <geoff_leyland@fastmail.fm> wrote:
> On 31/08/2011, at 7:36 AM, Alexander Gladysh wrote:
>
>> No, as I understand it, whole function must be pairs-free for this to
>> work. Maybe I'm wrong, that's a wild guess. (You may try to move the
>> loop to a separate function to try this hypothesis.)
>
> That doesn't seem to be the case:
>
> test.lua:
>
> local function a()
> local t = {}
> for i = 1, 100000 do
> t[i] = i
> end
>
> local ps, is = 0, 0
> for _, v in pairs(t) do
> ps = ps + v
> end
>
> for _, v in ipairs(t) do
> is = is + v
> end
>
> return ps, is
> end
>
> print(a())
>
> --
>
> $ luajit -jdump test.lua
> ...
> ---- TRACE 3 start test.lua:12
>
> That is, a trace was started at line 12 - the start of the ipairs loop (What I don't understand in this case is why a trace was never even attempted for the pairs loop)
As I understand it, traces are picked at random. A single call of a()
would not prove a thing.
Alexander.
- References:
- How to clone a table in LJ2-friendly way?, Alexander Gladysh
- Re: How to clone a table in LJ2-friendly way?, Dimiter "malkia" Stanev
- Re: How to clone a table in LJ2-friendly way?, Dimiter "malkia" Stanev
- Re: How to clone a table in LJ2-friendly way?, Alexander Gladysh
- Re: How to clone a table in LJ2-friendly way?, Dimiter "malkia" Stanev
- Re: How to clone a table in LJ2-friendly way?, Dimiter "malkia" Stanev
- Re: How to clone a table in LJ2-friendly way?, Alexander Gladysh
- Re: How to clone a table in LJ2-friendly way?, Dimiter "malkia" Stanev
- Re: How to clone a table in LJ2-friendly way?, Alexander Gladysh
- Re: How to clone a table in LJ2-friendly way?, Dimiter "malkia" Stanev
- Re: How to clone a table in LJ2-friendly way?, Alexander Gladysh
- Re: How to clone a table in LJ2-friendly way?, Geoff Leyland