HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

What's more efficient

11-13-2007, 12:18 AM#1
jw232
Both do the same thing, which one is more efficient
Code:
if a
    if b
    if c
or
Code:
if a and b

if a and c
11-13-2007, 12:30 AM#2
PipeDream
Try to construct an argument for why one would be faster
11-13-2007, 12:43 AM#4
jw232
One has 3 ifs and the other 2
11-13-2007, 01:13 AM#5
PipeDream
that's an interesting idea. However, consider which code gets executed.
For the first, we execute:
a, jump
b, jump
c, jump
For the second, we execute:
a, jump (short circuit and : if a and b <-> if a if b)
b, jump
a, jump
c, jump
Seems like #2 has to run more to me, so I would expect that to be slower.