View Single Post
Old 03-01-2017, 11:31 AM   #88 (permalink)
skybolt
deviant
 
Join Date: Oct 2016
Location: Seattle, WA
Posts: 69

s2k - '02 Honda s2000
Thanks: 12
Thanked 47 Times in 35 Posts
That's precisely the kind of conditional I'm curious about -- I want to be able to change display output based on conditions, but after watching the memory footprint of this app get larger and larger, I want to do it in the most computationally efficient manner.

Is the following code (assume it's all inside a single function and variable zap isn't static or persistent:

Code:
int zap = (calculationToGetZap(parameter) );

if (zap > 50) {
  doBigThing();
}

else if (zap > 100) {
 doBiggerThing();
}

else {
 doTinyThing(); 
}
the same (in terms of memory allocation and other resource efficiency) as this:

Code:
if ((calculationToGetZap(parameter)  > 50) {
  doBigThing();
}

else if ((calculationToGetZap(parameter)  > 100) {
 doBiggerThing();
}

else {
 doTinyThing(); 
}
  Reply With Quote