generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: pairs() and next

Previous Thread :: Next Thread 
RATEXmegaGAMER is not online. RATEXmegaGAMER
Joined: 10 Dec 2010
Total Posts: 4046
17 Nov 2011 01:24 PM
Would next be faster than pairs() since pairs() calls next?
Report Abuse
TheMyrco is not online. TheMyrco
Joined: 13 Aug 2011
Total Posts: 15105
17 Nov 2011 01:26 PM
pairs, I believe.
Report Abuse
crazypotato4 is not online. crazypotato4
Joined: 22 Feb 2010
Total Posts: 20000
17 Nov 2011 01:35 PM
by a negligable amount, yes
Report Abuse
TheMyrco is not online. TheMyrco
Joined: 13 Aug 2011
Total Posts: 15105
17 Nov 2011 01:38 PM
Plus pairs make Telamon mad.
Report Abuse
pwnedu46 is not online. 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
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
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 is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
18 Nov 2011 03:10 AM
[ Content Deleted ]
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
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 is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
18 Nov 2011 05:26 AM
[ Content Deleted ]
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
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 is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
18 Nov 2011 05:37 AM
[ Content Deleted ]
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
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 is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
18 Nov 2011 05:49 AM
[ Content Deleted ]
Report Abuse
TheMyrco is not online. 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
Scriptishish is not online. Scriptishish
Joined: 16 Oct 2007
Total Posts: 1231
18 Nov 2011 11:42 AM
My scripting style is the crumpliest :3
Report Abuse
NXTBoy is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image