SA-MP Forums Archive
What's faster ? Arrays or Foreach - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: What's faster ? Arrays or Foreach (/showthread.php?tid=620204)



What's faster ? Arrays or Foreach - NeXoR - 27.10.2016

Hey guys, I have read once a thread that a regular variable will always be faster than an array, which actually makes sense (it was explained with an Assembly example).
I have seen in other thread that native & inbuilt functions will always be faster than PAWN scripted functions, something with the compile progress or something.
So basically, what could be actually faster ?
PHP код:
if(!Iter_Contains(Adminsplayerid)) 
or
PHP код:
if(!PlayerInfo[playerid][pAdmin]) 



Re: What's faster ? Arrays or Foreach - Stinged - 27.10.2016

It depends on what you're actually trying to do.

Having an 'Admins' iterator will make it much faster to loop through the online admins.
While using the second one is usually used to save stats (Enum), so creating an iterator for every stat you wanna save is a very bad idea.


Re: What's faster ? Arrays or Foreach - Yashas - 27.10.2016

Use both, iterator to loop and the array to check admin level.


Re: What's faster ? Arrays or Foreach - NeXoR - 27.10.2016

Quote:
Originally Posted by Stinged
Посмотреть сообщение
It depends on what you're actually trying to do.

Having an 'Admins' iterator will make it much faster to loop through the online admins.
While using the second one is usually used to save stats (Enum), so creating an iterator for every stat you wanna save is a very bad idea.
Thanks.

Quote:
Originally Posted by Yashas
Посмотреть сообщение
Use both, iterator to loop and the array to check admin level.
Exactly what I am doing.