[REP++] Loop Optimize?
#1

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++)
Reply
#2

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)