[RFA 1/2] Speed up dict_hash
Tom Tromey
tom@tromey.com
Sat Nov 4 16:14:00 GMT 2017
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-04 Tom Tromey <tom@tromey.com>
* dictionary.c (dict_hash): Move "TKB" check into the "switch".
---
gdb/ChangeLog | 4 ++++
gdb/dictionary.c | 32 ++++++++++++++++----------------
2 files changed, 20 insertions(+), 16 deletions(-)
diff --git a/gdb/dictionary.c b/gdb/dictionary.c
index b2cfca28ab..702cd60c2a 100644
--- a/gdb/dictionary.c
+++ b/gdb/dictionary.c
@@ -796,17 +796,6 @@ dict_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 '$':
@@ -828,14 +817,25 @@ dict_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;
}
--
2.13.6
More information about the Gdb-patches
mailing list