[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: table library changes (was Re: table.new in 5.3?)
- From: Sean Conner <sean@...>
- Date: Mon, 25 Nov 2013 22:52:35 -0500
It was thus said that the Great Coda Highland once stated:
> On Mon, Nov 25, 2013 at 7:03 PM, Sean Conner <sean@conman.org> wrote:
> > It was thus said that the Great John Hind once stated:
> >
> >> Clearly, the optimised algorithm could be written in C as a multi-value
> >> remove library function, and like any algorithm it will be a faster in C
> >> than in Lua. But I do not think it will be sufficiently faster to justify
> >> its place in a C library.
> >
> > I actually went to the trouble to measure the code and indeed, the
> > "optimized" version does indeed run faster (about 10x), *BUT* it does *NOT*
> > produce identical results.
> >
> > I realize you were trying to prove a point here, but it might be made a
> > bit better if both code fragments actually did identical work.
>
> What's the difference?
The size of the resulting arrays (original: 9909 "optimized": 9899) and 90
incorrect values:
index orig optmized
-------------------------
10 11 10
11 13 102
12 15 103
13 17 104
14 19 105
15 21 106
16 23 107
17 25 108
18 27 109
19 29 110
20 31 111
21 33 112
22 35 113
23 37 114
24 39 115
25 41 116
26 43 117
27 45 118
28 47 119
29 49 120
30 51 121
31 53 122
... and so on
> And would it help to make the final loop
> "table.remove(t, i)" instead of "t[i] = nil"?
Nope. Makes it worse.
-spc