public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* PATCH: Small merge speed up
@ 2005-05-09  6:56 H. J. Lu
  2005-05-09 14:16 ` Alan Modra
  0 siblings, 1 reply; 2+ messages in thread
From: H. J. Lu @ 2005-05-09  6:56 UTC (permalink / raw)
  To: binutils

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;

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: PATCH: Small merge speed up
  2005-05-09  6:56 PATCH: Small merge speed up H. J. Lu
@ 2005-05-09 14:16 ` Alan Modra
  0 siblings, 0 replies; 2+ messages in thread
From: Alan Modra @ 2005-05-09 14:16 UTC (permalink / raw)
  To: H. J. Lu; +Cc: binutils

On Sun, May 08, 2005 at 08:44:53PM -0700, H. J. Lu wrote:
> Does this get the same values faster?

You might find the increment in the loop is free on certain superscalar
processors.  You'd need to measure on a number of different processors.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-05-09 14:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-09  6:56 PATCH: Small merge speed up H. J. Lu
2005-05-09 14:16 ` Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).