Bug 52656

Summary: Code clean up (remove useless tests)
Product: Apache httpd-2 Reporter: Christophe JAILLET <christophe.jaillet>
Component: AllAssignee: Apache HTTPD Bugs Mailing List <bugs>
Status: RESOLVED FIXED    
Severity: minor Keywords: PatchAvailable
Priority: P2    
Version: 2.5-HEAD   
Target Milestone: ---   
Hardware: All   
OS: All   
Attachments: Proposed patch

Description Christophe JAILLET 2012-02-13 16:25:15 UTC
Created attachment 28320 [details]
Proposed patch

Hi,

In many places of httpd, we are skipping white spaces with code that looks like :
   while (*l && apr_isspace(*l)) {
       ++l;
   }

The first test against *l is IMO useless and could be removed in order to improve the generated code.
I.e. :
   while (apr_isspace(*l)) {
       ++l;
   }

apr_isspace is in fact turned to a call to isspace by the apr library and isspace(0) returns 0.


I also made some measurement.
The version with the test against *l is faster ONLY when the string to scan is EMPTY. In this case it is more or less 50% faster to completely avoid the call to isspace.
In ALL other cases, removing the first test is about 15% faster.


The proposed patch removes these, IMO, useless tests.
The modified files are :

 modules/cache/cache_storage.c     |    2 +-
 modules/cache/mod_cache_disk.c    |    2 +-
 modules/cache/mod_disk_cache.c    |    2 +-
 modules/filters/mod_proxy_html.c  |    2 +-
 modules/mappers/mod_imagemap.c    |    2 +-
 modules/mappers/mod_negotiation.c |    8 ++++----
 modules/mappers/mod_rewrite.c     |    2 +-
 modules/metadata/mod_cern_meta.c  |    2 +-
 modules/metadata/mod_headers.c    |    2 +-
 modules/metadata/mod_mime_magic.c |    2 +-
 modules/proxy/mod_proxy_http.c    |    2 +-
 server/util.c                     |    8 ++++----
 server/util_script.c              |    2 +-
 support/httxt2dbm.c               |    2 +-
 14 files changed, 20 insertions(+), 20 deletions(-)
Comment 1 Christophe JAILLET 2012-07-10 21:22:32 UTC
Patch must be revised.