This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB 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]

[binutils-gdb] Simplify the psymbol hash function


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e793c052f9d9548442a46817998a46cbca4ccb70

commit e793c052f9d9548442a46817998a46cbca4ccb70
Author: Tom Tromey <tom@tromey.com>
Date:   Thu Nov 2 12:48:44 2017 -0600

    Simplify the psymbol hash function
    
    This patch simplifies the psymbol_hash function, by changing it not to
    examine the contents of the symbol's name.  This change just mirrors
    what psymbol_compare already does -- it is checking for name equality,
    which is ok because symbol names are interned in symbol_set_names.
    
    This change speeds up psymbol reading.  "gdb -nx -batch gdb"
    previously took ~1.8 seconds on my machine, and with this patch it now
    takes ~1.7 seconds.
    
    gdb/ChangeLog
    2017-11-09  Tom Tromey  <tom@tromey.com>
    
    	* psymtab.c (psymbol_hash): Do not hash string contents.
    	(psymbol_compare): Add comment.

Diff:
---
 gdb/ChangeLog | 5 +++++
 gdb/psymtab.c | 7 ++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f3c77cd..22434aa 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
 2017-11-09  Tom Tromey  <tom@tromey.com>
 
+	* psymtab.c (psymbol_hash): Do not hash string contents.
+	(psymbol_compare): Add comment.
+
+2017-11-09  Tom Tromey  <tom@tromey.com>
+
 	* dictionary.c (dict_hash): Move "TKB" check into the "switch".
 
 2017-11-08  Joel Brobecker  <brobecker@adacore.com>
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 29d40dc..06a65bf 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1548,7 +1548,9 @@ psymbol_hash (const void *addr, int length)
   h = hash_continue (&lang, sizeof (unsigned int), h);
   h = hash_continue (&domain, sizeof (unsigned int), h);
   h = hash_continue (&theclass, sizeof (unsigned int), h);
-  h = hash_continue (psymbol->ginfo.name, strlen (psymbol->ginfo.name), h);
+  /* Note that psymbol names are interned via symbol_set_names, so
+     there's no need to hash the contents of the name here.  */
+  h = hash_continue (&psymbol->ginfo.name, sizeof (psymbol->ginfo.name), h);
 
   return h;
 }
@@ -1568,6 +1570,9 @@ psymbol_compare (const void *addr1, const void *addr2, int length)
 	  && sym1->ginfo.language == sym2->ginfo.language
           && PSYMBOL_DOMAIN (sym1) == PSYMBOL_DOMAIN (sym2)
           && PSYMBOL_CLASS (sym1) == PSYMBOL_CLASS (sym2)
+	  /* Note that psymbol names are interned via
+	     symbol_set_names, so there's no need to compare the
+	     contents of the name here.  */
           && sym1->ginfo.name == sym2->ginfo.name);
 }


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