Summary: | Attempted optimisation does not (improve performance) | ||
---|---|---|---|
Product: | Tomcat Connectors | Reporter: | Thomas Schodt <apache> |
Component: | mod_jk | Assignee: | Tomcat Developers Mailing List <dev> |
Status: | RESOLVED FIXED | ||
Severity: | enhancement | ||
Priority: | P2 | ||
Version: | 1.2.37 | ||
Target Milestone: | --- | ||
Hardware: | All | ||
OS: | All |
Description
Thomas Schodt
2014-03-21 12:15:52 UTC
Patch tested on linux. $ svn diff jk_map.c Index: jk_map.c =================================================================== --- jk_map.c (revision 1579918) +++ jk_map.c (working copy) @@ -36,8 +36,8 @@ #define JK_MAP_REFERENCE (".reference") #define JK_MAP_REFERENCE_SZ (strlen(JK_MAP_REFERENCE)) -/* Compute the "checksum" for a key, consisting of the first - * 4 bytes, packed into an int. +/* Compute the "checksum" for a key, consisting of + * a digest of the string (same as java hashcode). * This checksum allows us to do a single integer * comparison as a fast check to determine whether we can * skip a strcmp @@ -45,23 +45,13 @@ #define COMPUTE_KEY_CHECKSUM(key, checksum) \ { \ const char *k = (key); \ - unsigned int c = (unsigned int)*k; \ - (checksum) = c; \ - (checksum) <<= 8; \ - if (c) { \ - c = (unsigned int)*++k; \ - checksum |= c; \ + (checksum) = 0; \ + unsigned int c = (unsigned int)*k++; \ + while(c) { \ + (checksum) *= 31; \ + (checksum) += c; \ + c = (unsigned int)*k++; \ } \ - (checksum) <<= 8; \ - if (c) { \ - c = (unsigned int)*++k; \ - checksum |= c; \ - } \ - (checksum) <<= 8; \ - if (c) { \ - c = (unsigned int)*++k; \ - checksum |= c; \ - } \ } static volatile int global_map_id = 0; |