diff options
author | Tom Tromey <tom@tromey.com> | 2019-03-01 19:55:46 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2019-03-15 16:02:08 -0600 |
commit | 1b7a07cba0aa096c2eb66895ef339aa5143e9995 (patch) | |
tree | 817c4e8fe6ceb3e62133833a2c40cf58e4f5f629 /gdb | |
parent | 3db066bcd5bac9a8d6be85ea4cfa8f52dbdcc600 (diff) | |
download | gdb-1b7a07cba0aa096c2eb66895ef339aa5143e9995.zip gdb-1b7a07cba0aa096c2eb66895ef339aa5143e9995.tar.gz gdb-1b7a07cba0aa096c2eb66895ef339aa5143e9995.tar.bz2 |
Use bitset for demangled_hash_languages
I noticed that objfile_per_bfd_storage::demangled_hash_languages is a
std::vector, which seemed quite large for something that,
fundamentally, can be represented as a bitset. This patch
reimplements it as a std::bitset.
gdb/ChangeLog
2019-03-15 Tom Tromey <tom@tromey.com>
* objfiles.h (struct objfile_per_bfd_storage)
<demangled_hash_languages>: Now a bitset.
* minsyms.c (add_minsym_to_demangled_hash_table): Update.
(lookup_minimal_symbol): Update.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/minsyms.c | 18 | ||||
-rw-r--r-- | gdb/objfiles.h | 7 |
3 files changed, 21 insertions, 11 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 2d6d895..867df17 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,12 @@ 2019-03-15 Tom Tromey <tom@tromey.com> + * objfiles.h (struct objfile_per_bfd_storage) + <demangled_hash_languages>: Now a bitset. + * minsyms.c (add_minsym_to_demangled_hash_table): Update. + (lookup_minimal_symbol): Update. + +2019-03-15 Tom Tromey <tom@tromey.com> + * minsyms.h (class minimal_symbol_reader) <record_with_info>: Don't return the symbol. * coffread.c (record_minimal_symbol): Use record_full. diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 0513cfe..cbb45f1 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -160,11 +160,7 @@ add_minsym_to_demangled_hash_table (struct minimal_symbol *sym, unsigned int hash = search_name_hash (MSYMBOL_LANGUAGE (sym), MSYMBOL_SEARCH_NAME (sym)); - auto &vec = objfile->per_bfd->demangled_hash_languages; - auto it = std::lower_bound (vec.begin (), vec.end (), - MSYMBOL_LANGUAGE (sym)); - if (it == vec.end () || *it != MSYMBOL_LANGUAGE (sym)) - vec.insert (it, MSYMBOL_LANGUAGE (sym)); + objfile->per_bfd->demangled_hash_languages.set (MSYMBOL_LANGUAGE (sym)); struct minimal_symbol **table = objfile->per_bfd->msymbol_demangled_hash; @@ -354,8 +350,12 @@ lookup_minimal_symbol (const char *name, const char *sfile, { /* Once for each language in the demangled hash names table (usually just zero or one languages). */ - for (auto lang : objfile->per_bfd->demangled_hash_languages) + for (unsigned iter = 0; iter < nr_languages; ++iter) { + if (!objfile->per_bfd->demangled_hash_languages.test (iter)) + continue; + enum language lang = (enum language) iter; + unsigned int hash = (lookup_name.search_name_hash (lang) % MINIMAL_SYMBOL_HASH_SIZE); @@ -497,8 +497,12 @@ iterate_over_minimal_symbols /* The second pass is over the demangled table. Once for each language in the demangled hash names table (usually just zero or one). */ - for (auto lang : objf->per_bfd->demangled_hash_languages) + for (unsigned liter = 0; liter < nr_languages; ++liter) { + if (!objf->per_bfd->demangled_hash_languages.test (liter)) + continue; + + enum language lang = (enum language) liter; const language_defn *lang_def = language_def (lang); symbol_name_matcher_ftype *name_match = get_symbol_name_matcher (lang_def, lookup_name); diff --git a/gdb/objfiles.h b/gdb/objfiles.h index c5ce9ee..47df002 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -28,6 +28,7 @@ #include "registry.h" #include "gdb_bfd.h" #include "psymtab.h" +#include <bitset> #include <vector> #include "common/next-iterator.h" #include "common/safe-iterator.h" @@ -313,10 +314,8 @@ struct objfile_per_bfd_storage minimal_symbol *msymbol_demangled_hash[MINIMAL_SYMBOL_HASH_SIZE] {}; /* All the different languages of symbols found in the demangled - hash table. A flat/vector-based map is more efficient than a map - or hash table here, since this will only usually contain zero or - one entries. */ - std::vector<enum language> demangled_hash_languages; + hash table. */ + std::bitset<nr_languages> demangled_hash_languages; }; /* Master structure for keeping track of each file from which |