[binutils-gdb] Combine two cases in cooked_index_functions::search
Tom Tromey via Gdb-cvs <[email protected]>
| Newsgroups | gmane.comp.gdb.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=77f460c9fd42d91a886b637f31ea2d3e267255c3 commit 77f460c9fd42d91a886b637f31ea2d3e267255c3 Author: Tom Tromey <[email protected]> Date: Fri Nov 21 09:43:11 2025 -0700 Combine two cases in cooked_index_functions::search This combines a couple of 'if' statements in cooked_index_functions::search. This simplifies the code a little and also makes a subsequent patch a bit simpler as well. Acked-By: Tom de Vries <[email protected]> Approved-By: Simon Marchi <[email protected]> Diff: --- gdb/dwarf2/read.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 520b98c3485..a9796daa6dd 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -14145,25 +14145,22 @@ cooked_index_functions::search || !entry->matches (domain)) continue; - if (lang_matcher != nullptr) + /* If LANG_MATCHER is non-NULL, try to skip CUs with a + non-matching language. The other case here is a bit of a + hack to support .gdb_index. Since .gdb_index does not + record languages, and since we want to know the language + to avoid excessive CU expansion due to false matches, if + we see a symbol with an unknown language we find the CU's + language. Only the .gdb_index reader creates such + symbols. */ + enum language entry_lang = entry->lang; + if (lang_matcher != nullptr || entry_lang == language_unknown) { - /* Try to skip CUs with non-matching language. */ entry->per_cu->ensure_lang (per_objfile); - if (!entry->per_cu->maybe_multi_language () + if (lang_matcher != nullptr + && !entry->per_cu->maybe_multi_language () && !lang_matcher (entry->per_cu->lang ())) continue; - } - - /* This is a bit of a hack to support .gdb_index. Since - .gdb_index does not record languages, and since we want - to know the language to avoid excessive CU expansion due - to false matches, if we see a symbol with an unknown - language we find the CU's language. Only the .gdb_index - reader creates such symbols. */ - enum language entry_lang = entry->lang; - if (entry_lang == language_unknown) - { - entry->per_cu->ensure_lang (per_objfile); entry_lang = entry->per_cu->lang (); }