This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] Speed up dict_hash
- From: Tom Tromey <tromey at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 9 Nov 2017 15:37:45 -0000
- Subject: [binutils-gdb] Speed up dict_hash
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7e8835c5f44931d02ecd8c8ba3d167e891981d24
commit 7e8835c5f44931d02ecd8c8ba3d167e891981d24
Author: Tom Tromey <tom@tromey.com>
Date: Wed Nov 1 11:15:06 2017 -0600
Speed up dict_hash
This speeds up dict_hash a bit, by moving the "TKB" check into the
switch in the loop.
For "gdb -nx -readnow -batch gdb", this improves the time from ~9.8s
before to ~8.5s afterward.
gdb/ChangeLog
2017-11-09 Tom Tromey <tom@tromey.com>
* dictionary.c (dict_hash): Move "TKB" check into the "switch".
Diff:
---
gdb/ChangeLog | 4 ++++
gdb/dictionary.c | 32 ++++++++++++++++----------------
2 files changed, 20 insertions(+), 16 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index cc38854..f3c77cd 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+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>
* ada-exp.y (write_var_from_sym): Remove parameter
diff --git a/gdb/dictionary.c b/gdb/dictionary.c
index 8277c5d..fb30753 100644
--- a/gdb/dictionary.c
+++ b/gdb/dictionary.c
@@ -790,17 +790,6 @@ default_search_name_hash (const char *string0)
hash = 0;
while (*string)
{
- /* Ignore "TKB" suffixes.
-
- These are used by Ada for subprograms implementing a task body.
- For instance for a task T inside package Pck, the name of the
- subprogram implementing T's body is `pck__tTKB'. We need to
- ignore the "TKB" suffix because searches for this task body
- subprogram are going to be performed using `pck__t' (the encoded
- version of the natural name `pck.t'). */
- if (strcmp (string, "TKB") == 0)
- return hash;
-
switch (*string)
{
case '$':
@@ -822,14 +811,25 @@ default_search_name_hash (const char *string0)
return hash;
hash = 0;
string += 2;
- break;
+ continue;
}
- /* FALL THROUGH */
- default:
- hash = SYMBOL_HASH_NEXT (hash, *string);
- string += 1;
+ break;
+ case 'T':
+ /* Ignore "TKB" suffixes.
+
+ These are used by Ada for subprograms implementing a task body.
+ For instance for a task T inside package Pck, the name of the
+ subprogram implementing T's body is `pck__tTKB'. We need to
+ ignore the "TKB" suffix because searches for this task body
+ subprogram are going to be performed using `pck__t' (the encoded
+ version of the natural name `pck.t'). */
+ if (strcmp (string, "TKB") == 0)
+ return hash;
break;
}
+
+ hash = SYMBOL_HASH_NEXT (hash, *string);
+ string += 1;
}
return hash;
}