httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Jagielski <...@jaguNET.com>
Subject Re: [PATCH] proxy/ajp_header.c: Fix header detection
Date Fri, 31 Aug 2007 12:46:26 GMT

On Aug 31, 2007, at 5:11 AM, Martin Kraemer wrote:

>
> Please go for "obvious" algorithms, or simply automate them (as in
> the example macro above) rather than "coding in assembler code" for
> efficiency, dropping even the slightest trace of explanation what
> the code is intended to do, and leaving unmaintainable code behind  
> you.
>
> Because the strcmp() is so obvious, and does exactly what it's
> supposed to do in this case, namely compare two strings over their
> complete length, I went against the choice of "using memcmp for
> efficiency" to save myself and many others from long nights of
> head-scratching and -bashing to find out where some off-by-one
> error was lingering deep in the AJP code.
>

+++1 :)

If this was in some deeply tight loop, then *maybe* the
optimization might be worth it (as Martin says, a macro
wrapper would be best due to the size of the const string
is known by the compiler and this counting those chars
is not something the coder needs to worry about), but
readability counts for an awful lot :)

Of course, to be honest, lookup_builtin_method() suffers
from the same "unreadability" but at least it is documented ;)


Mime
View raw message