apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cliff Woolley <jwool...@virginia.edu>
Subject Re: apr_status_t testing against APR_SUCCESS usage question
Date Mon, 27 Dec 2004 17:22:26 GMT
On Mon, 27 Dec 2004, Garrett Rooney wrote:

> > This seems to defeat the point of having an APR_SUCCESS in the first
> > place. It's also (at least in my eyes) slightly less intuitive than
> > explicit testing.
>
> Part of the definition of apr_status_t is the fact that APR_SUCCESS is
> defined to be zero.  This is by design, because success is the common
> case you test for, and comparing against zero is fast for most
> processors.

But because it is defined to be zero,

> >     if (rv != APR_SUCCESS) {
> >         return rv;
> >     }
> >

will be equivalent to and just as fast as

> >     if (!rv) {
> >         return rv;
> >     }

on any remotely reasonable compiler.  I believe Mihai is correct that the
majority of our code uses the rv != APR_SUCCESS idiom rather than the !rv
idiom.  I actually kind of like the spelled out APR_SUCCESS version,
personally.

--Cliff

Mime
View raw message