$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r48617 - trunk/tools/jam/src
From: grafikrobot_at_[hidden]
Date: 2008-09-05 12:26:46
Author: grafik
Date: 2008-09-05 12:26:45 EDT (Fri, 05 Sep 2008)
New Revision: 48617
URL: http://svn.boost.org/trac/boost/changeset/48617
Log:
Minor perf improvement for bjam by replacing hash function with faster version. Only 1% diff for Boost tree.
Text files modified: 
   trunk/tools/jam/src/build.jam |    13 ++++++++++++-                           
   trunk/tools/jam/src/hash.c    |    29 +++++++++++++++++++++++++++--           
   2 files changed, 39 insertions(+), 3 deletions(-)
Modified: trunk/tools/jam/src/build.jam
==============================================================================
--- trunk/tools/jam/src/build.jam	(original)
+++ trunk/tools/jam/src/build.jam	2008-09-05 12:26:45 EDT (Fri, 05 Sep 2008)
@@ -25,6 +25,11 @@
     debug = true ;
 }
 
+if --profile in $(ARGV)
+{
+    profile = true ;
+}
+
 # Attempt to generate and/or build the grammar?
 if --grammar in $(ARGV)
 {
@@ -33,7 +38,8 @@
 
 # Do we need to add a default build type argument?
 if ! ( --release in $(ARGV) ) &&
-   ! ( --debug in $(ARGV) )
+   ! ( --debug in $(ARGV) ) &&
+   ! ( --profile in $(ARGV) )
 {
     ARGV += --release ;
 }
@@ -171,6 +177,7 @@
     :
     [ opt --release : -Wl,-x -O3 -finline-functions ]
     [ opt --debug : -g -O0 -fno-inline -pg ]
+    [ opt --profile : -Wl,-x -O3 -finline-functions -g -pg ]
     -I$(--python-include) -I$(--extra-include)
     : -L$(--python-lib[1]) -l$(--python-lib[2]) ;
 ## GCC 2.x, 3.x, 4.x
@@ -428,6 +435,10 @@
 {
     locate-target = [ .path $(locate-target)$(.)debug ] ;
 }
+if $(profile)
+{
+    locate-target = [ .path $(locate-target)$(.)profile ] ;
+}
 else
 {
     locate-target = [ .path $(locate-target) ] ;
Modified: trunk/tools/jam/src/hash.c
==============================================================================
--- trunk/tools/jam/src/hash.c	(original)
+++ trunk/tools/jam/src/hash.c	2008-09-05 12:26:45 EDT (Fri, 05 Sep 2008)
@@ -100,15 +100,40 @@
 static void hash_mem_finalizer(char * key, struct hash * hp);
 #endif
 
-static unsigned int hash_keyval( const char * key_ )
+static unsigned int jenkins_one_at_a_time_hash(const unsigned char *key)
+{
+    unsigned int hash = 0;
+    size_t i;
+
+    while ( *key )
+    {
+        hash += *key++;
+        hash += (hash << 10);
+        hash ^= (hash >> 6);
+    }
+    hash += (hash << 3);
+    hash ^= (hash >> 11);
+    hash += (hash << 15);
+    return hash;
+}
+
+static unsigned int knuth_hash(const unsigned char *key)
 {
-    const unsigned char * key = (const unsigned char *)key_;
     unsigned int keyval = *key;
     while ( *key )
         keyval = keyval * 2147059363 + *key++;
     return keyval;
 }
 
+static unsigned int hash_keyval( const char * key_ )
+{
+    /**
+    return knuth_hash((const unsigned char *)key_);
+    /*/
+    return jenkins_one_at_a_time_hash((const unsigned char *)key_);
+    /**/
+}
+
 #define hash_bucket(hp,keyval) ((hp)->tab.base + ( (keyval) % (hp)->tab.nel ))
 
 /*  Find the hash item for the given data. Returns pointer to the