@kugel- commented on this pull request.
In src/tagmanager/tm_workspace.c:
> - if (*header == NULL && g_strcmp0(hdr_comps[0], src_comps[0]) == 0) - *header = hdr; - g_hash_table_add(includes, hdr); - g_strfreev(hdr_comps); + for (j = 0; j < tm_files->len; j++) + { + TMSourceFile *hdr = tm_files->pdata[j]; + gchar **hdr_comps = g_strsplit(hdr->short_name, ".", 2); + + if (g_strcmp0(hdr_comps[0], src_comps[0]) == 0)
I think this can be improved.
We're called for a foo.c and loop over all includes here. We have the file name already, and then lookup the TMSourceFile
(and then for every TMSourceFile
we check if the file name is foo.h).
Instead, we can already check for foo.h earlier (when looking up the TMSourceFile
). And then we can return a copy (or ref?) of the GPtrArray
as header_candidates
instead of creating a new list. Something like this:
GPtrArray *tm_files = g_hash_table_lookup(theWorkspace->source_file_map, hdr_name);
if (g_strcmp0(hdr_name, src_comps[0]))
Perhaps it would make sense to separate this part out of get_includes()
and make a distinct g_hash_table_lookup()
for the expected header name? Hm but then it wouldn't depend on foo.c actually including foo.h (could also be seen as a good thing, not sure)
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.