Tom Lane wrote:
> Neil Conway <[EMAIL PROTECTED]> writes:
> > While I still think we're on pretty solid ground assuming this
> > optimization is going to be made, I'm fine with defining something like
> > const_strlen() that uses sizeof(). Also, we can guard against programmer
> > mistakes via __builtin_constant_p() when using GCC.
> 
> I think both you and Bruce are missing the really fundamental point
> here.  You are both optimizing on the grounds that there is no god but
> RMS and his prophet is GCC.  I have a somewhat wider view of which
> compilers we want to target.

Just to clarify, I am not against the use of sizeof() and I understand
Tom's point.  My issue was the use of a constant that doesn't clearly
document.

As I remember the ability of the compiler to evaluate strlen is that if
there is a prototype in scope for strlen() that is somehow different
from the compilers then the compiler can not make the optimization.  I
see my BSD using:

        size_t   strlen __P((const char *));

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  [EMAIL PROTECTED]               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to [EMAIL PROTECTED] so that your
      message can get through to the mailing list cleanly

Reply via email to