Processor Time

From: Brian Christopher Guilbault (guil9964@nova.gmi.edu)
Date: 07/12/96


Hiyaz-

This question kind of goes out to you CS students or those who know a bit 
about theory I guess. I was wondering which is more processor efficient, 
a nested "if" or a single if composed of multiple checks. For example:

if (GET_CLASS(ch) == CLASS_WARRIOR)
  if (GET_LEVEL(ch) >=15)
    perform_this_function(ch);

vs.

if (GET_CLASS(ch) == CLASS_WARRIOR && GET_LEVEL(ch) >= 15)
  perform_this_function(ch); 

I am of the opinion that a switch is more efficient than a bunch of "else 
if's" as well. The reason I ask is because my code, as well as the stock 
circle has A LOT of each of these. I was thinking about going through and 
(a little at a time) changing these. I know that the time difference in 
these is really small, but perhaps there is a long term benefit?

BTW, I did check my C books and couldn't find anything that would answer 
this question.

Thanks,
  -Brian

-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Brian Guilbault - GMI Engineering Institute
E-mail: guil9964@gmi.edu, dante@i-55.com
WWW: http://www.gmi.edu/~guil9964
QuarantineMUD: Telnet to exit1.i-55.com 4000
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+



This archive was generated by hypermail 2b30 : 12/07/00 PST