Bug 52656 - Code clean up (remove useless tests)
Summary: Code clean up (remove useless tests)
Status: RESOLVED FIXED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: All (show other bugs)
Version: 2.5-HEAD
Hardware: All All
: P2 minor (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords: PatchAvailable
Depends on:
Blocks:
 
Reported: 2012-02-13 16:25 UTC by Christophe JAILLET
Modified: 2013-05-21 20:08 UTC (History)
0 users



Attachments
Proposed patch (8.39 KB, patch)
2012-02-13 16:25 UTC, Christophe JAILLET
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.