[REP++] Loop Optimize? - 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: [REP++] Loop Optimize? (
/showthread.php?tid=627157)
[REP++] Loop Optimize? -
KessMan - 24.01.2017
How it is faster and better?
Method 1 or 2? Why?
METHOD 1:
Код HTML:
for(new r = 0; r < cache_num_rows(); ++r)
for(new h = 0; h < sizeof(AllHouses); h++)
for(new h = 0; h < sizeof(AllBizzs); h++)
METHOD 2:
Код HTML:
for(new r = 0, c = cache_num_rows(); r < c; ++r)
for(new h = 0, s = sizeof(AllHouses); h < s; h++)
for(new h = 0, a = sizeof(AllBizzs); h < a; h++)
Re: [REP++] Loop Optimize? -
Vince - 24.01.2017
Sizeof is an operator, not a function. It gets evaluated at compile time and has no impact on performance. Use method 1. For a function call use method 2 so the function doesn't get invoked again with every iteration.