From: "John Marshall" <[EMAIL PROTECTED]> > >> if ((len = StrLen (Data.Field2)) > 0) RecordSize += len + 1; > > > > Since StrLen can't return < 0 > > Well, you and I know that (assuming no bugs in the implementation), but > does the compiler know that?
I don't think it really matters unless you deal with "strings" over 64K in length. :) > > how about > > > > if ((len = StrLen (Data.Field2))) > > RecordSize += len + 1; > > > > (The extra parens are sometimes the easiest way to turn off the usual > > warning about assignment within conditional). > > IMHO the *clearest* way to avoid that usual warning is to add an extra > explicit test, even if it is not strictly necessary. I was just tagging along with the example (and cross-fertilizing the warning thread). I don't use assignments within conditionals any more because I think it makes the code harder to read. > If you think dropping that > extra test has any effect whatsoever on the efficiency of the generated > code, then you need to spend some time playing with a disassembler. You're talking to the wrong guy, John. :) I am utterly against playing these sorts of games with the compiler (search for my name and "preoptimization"). I believe in writing the simplest possible code, making sure it works (with automated unit tests), then optimizing IFF necessary. -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
