Re: quick question.

From: Jeremy Elson (
Date: 07/31/95

> I've been coding for about 12 hours straight, so this might be a brainless
> question... but, is this statement redundant, or unneccessary? :
>   if (GET_ROOM_SPEC(ch->in_room) != NULL)
> couldn't the same thing be accomplished with this? :
>   if (GET_ROOM_SPEC(ch->in_room))
> I've noticed statements like the first one in lots of places in the circle
> code.   Wouldn't the program be slightly smaller with the second statment?
> Just curious...

I knew someone was going to ask me this eventually. :)

Yes, the statements are the same.  However I often choose the first
because it's clearer when someone not familiar with C is reading it.

As for the program being "smaller" -- the source code would be smaller
by several bytes (8 bytes, to be exact :-)), but the object code and
executable would be exactly identical on most compilers.

Note that there are many, many places in the code -- the if (x != 0)
case that you pointed out being only one out of a hundred examples --
where I've chosen to code something in a way that is maximally readable
and understandable, rather than maximally efficient or maximally

Yes, I know how to write mega-unreadable mega-efficient mega-small code,
but I only do that when either A) no one else is ever going to read the
code in the future, including me, or B) speed is absolutely critical.


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