How expensive is looping though a table

In my game i may have a table that looks like this with maybe 100 values or so

module.data = {
	['Bloxy_Cola'] = {
		DisplayName = 'Bloxy Cola',
		Value = 20,
		Weight = 100,
		RarityColor = rarityColors.Common,
		ViewportPosition = Vector3.new(-61.511, -1.008, -0.324),
		ViewportOrientation = Vector3.new(-3.756, 47.705, 11.278)
	},
	
	['Bloxy_Cola2'] = {
		DisplayName = 'Bloxy Cola2',
		Value = 20,
		Weight = 50,
		RarityColor = rarityColors.Common,
		ViewportPosition = Vector3.new(-61.511, -1.008, -0.324),
		ViewportOrientation = Vector3.new(-3.756, 47.705, 11.278)
	},
}

How expensive is an operation like

for dropID, dropData in module.data do

end

im sure it matters more or less depending on what you actually do with that data but how worried do i have to be about simply reading and maybe saving some of the info into vars?

1 Like

It’s not super expensive, you can loop through a table a lot of times without suffering any actual performance issue.

But, if you want to be more precautious then try looping in parallel luaU.

2 Likes

I haven’t truly dabbled in Parallel LuaU yet, but this resource might help!

1 Like

Honestly exiting and entering parallel threads is more expensive than looping :sweat_smile: The tradeoff isnt worth it in this case

3 Likes

Ah, sorry. As I said, I don’t know much parallel, so thank you for stepping in and correcting me.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.