This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: Small merge speed up


Does this get the same values faster?


H.J.
----
2005-05-08  H.J. Lu  <hongjiu.lu@intel.com>

	* merge.c (sec_merge_hash_lookup): Simplify length calculation.

--- bfd/merge.c.hash	2005-05-05 09:15:32.000000000 -0700
+++ bfd/merge.c	2005-05-08 20:38:36.000000000 -0700
@@ -150,12 +150,14 @@ sec_merge_hash_lookup (struct sec_merge_
 	    {
 	      hash += c + (c << 17);
 	      hash ^= hash >> 2;
-	      ++len;
 	    }
+	  len = (s - (const unsigned char *) string) - 1;
 	  hash += len + (len << 17);
 	}
       else
 	{
+	  unsigned int num;
+
 	  for (;;)
 	    {
 	      for (i = 0; i < table->entsize; ++i)
@@ -169,10 +171,10 @@ sec_merge_hash_lookup (struct sec_merge_
 		  hash += c + (c << 17);
 		  hash ^= hash >> 2;
 		}
-	      ++len;
 	    }
-	  hash += len + (len << 17);
-	  len *= table->entsize;
+	  len = (s - (const unsigned char *) string);
+	  num = len / table->entsize;
+	  hash += num + (num << 17);
 	}
       hash ^= hash >> 2;
       len += table->entsize;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]