[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apache-httpd-dev
Subject:    Re: [PATCH] proxy/ajp_header.c: Fix header detection
From:       Jim Jagielski <jim () jaguNET ! com>
Date:       2007-08-31 12:46:26
Message-ID: 790561EE-044E-4028-92A9-9342CD1D03ED () jaguNET ! com
[Download RAW message or body]


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 ;)

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic