Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What method of finding ojects in a table is faster?

Asked by
yellp1 193
4 years ago

What method of sorting through, and getting all the objects in a table, is faster?

for _, x in next, table do
    print(x)
end

--or

for i = 1, #table do
    local x = table[i]
    print(x)
end

These are going to be sorting through a lot of objects at a time (up to 1000) so I'd like to know which one is better for performance, OR if there's one faster that I'm not using :)

1 answer

Log in to vote
1
Answered by
mc3334 649 Moderation Voter
4 years ago

they both finish in a matter of miliseconds, however method 1 is specifically meant for going through tables and arrays, and method two is used for doing stuff to a group of data.

Ad

Answer this question