HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Which is faster?

02-03-2009, 08:36 PM#1
Bobo_The_Kodo
Even if it is barely, I've always wanted to know what is faster:

Collapse JASS:
                        set d = SquareRoot( ( x - .x ) * ( x - .x ) + ( y - .y ) * ( y - .y ) + ( z - .z ) * ( z - .z ) )
                        if d <= a + b then

or

Collapse JASS:
                        set d = ( x - .x ) * ( x - .x ) + ( y - .y ) * ( y - .y ) + ( z - .z ) * ( z - .z )
                        if d <= ( a + b ) * ( a + b ) then

or

Collapse JASS:
                        set d = ( x - .x ) * ( x - .x ) + ( y - .y ) * ( y - .y ) + ( z - .z ) * ( z - .z )
                        set r = a + b
                        if d <= r * r then
02-04-2009, 12:51 AM#2
Jazradel
Probably example 3.
02-04-2009, 01:04 AM#3
Anitarf
I'd say the second example, assuming that the local variable r from the third example doesn't need to be allocated in the second one. Then again, you could use a global, but the speed difference is not significant enough to tolerate such uglyness.