|
| 17 Nov 2011 01:24 PM |
| Would next be faster than pairs() since pairs() calls next? |
|
|
| Report Abuse |
|
|
TheMyrco
|
  |
| Joined: 13 Aug 2011 |
| Total Posts: 15105 |
|
| |
|
|
| 17 Nov 2011 01:35 PM |
| by a negligable amount, yes |
|
|
| Report Abuse |
|
|
TheMyrco
|
  |
| Joined: 13 Aug 2011 |
| Total Posts: 15105 |
|
|
| 17 Nov 2011 01:38 PM |
| Plus pairs make Telamon mad. |
|
|
| Report Abuse |
|
|
pwnedu46
|
  |
| Joined: 23 May 2009 |
| Total Posts: 7534 |
|
|
| 17 Nov 2011 02:58 PM |
"Plus pairs make Telamon mad."
A second bonus!! :D |
|
|
| Report Abuse |
|
|
|
| 18 Nov 2011 02:42 AM |
'next' is faster than pairs. That's the reason I always used next in the past. But now, I use pairs again. The gain is too small to be worth it.
I recommend using pairs. Even though using next is identical and faster. |
|
|
| Report Abuse |
|
|
Oysi
|
  |
| Joined: 06 Jul 2009 |
| Total Posts: 9058 |
|
| |
|
|
| 18 Nov 2011 03:20 AM |
"You're copying my scripting style, you stealful bass tard! =O"
If anything, YOU're the one copying my scripting style. |
|
|
| Report Abuse |
|
|
Oysi
|
  |
| Joined: 06 Jul 2009 |
| Total Posts: 9058 |
|
| |
|
|
| 18 Nov 2011 05:35 AM |
| Oysi, I created my own scripting style with time, and I actually don't see how our scripting styles are similar. |
|
|
| Report Abuse |
|
|
Oysi
|
  |
| Joined: 06 Jul 2009 |
| Total Posts: 9058 |
|
| |
|
|
| 18 Nov 2011 05:41 AM |
| I learned about next when reading the book Programming in Lua. It said that some people prefer to use next directly instead of pairs. After running some tests, I found out that next is faster than pairs which is faster than ipairs. For a good deal of time after that, I always used next. But, some time ago, I decided to turn back to pairs. The difference of efficiency is not worth it in my opinion. |
|
|
| Report Abuse |
|
|
Oysi
|
  |
| Joined: 06 Jul 2009 |
| Total Posts: 9058 |
|
| |
|
TheMyrco
|
  |
| Joined: 13 Aug 2011 |
| Total Posts: 15105 |
|
|
| 18 Nov 2011 09:17 AM |
| I claim my scripting style to be the cleanest. |
|
|
| Report Abuse |
|
|
|
| 18 Nov 2011 11:42 AM |
| My scripting style is the crumpliest :3 |
|
|
| Report Abuse |
|
|
NXTBoy
|
  |
| Joined: 25 Aug 2008 |
| Total Posts: 4533 |
|
|
| 18 Nov 2011 04:15 PM |
> Would next be faster than pairs() since pairs() calls next?
Marginally. Remember, `pairs` is only called once, before the iteration. These two ought to be completely equivalent ignoring the extra variable lookup in the first:
pairs(t) --Not actually used, just make it equivalent for k, v in next, t do -- ... end
and
for k, v in pairs(t) do -- ... end |
|
|
| Report Abuse |
|
|