]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
Add string cache and use it in cooked index
authorTom Tromey <tom@tromey.com>
Sun, 9 Mar 2025 16:14:34 +0000 (10:14 -0600)
committerTom Tromey <tom@tromey.com>
Mon, 10 Mar 2025 21:05:34 +0000 (15:05 -0600)
commit2609ee6f193505ec96552a9c33ecdea679242114
treeaaee82417fd309a6f29462ec704db67134e90941
parentc19c928f7b303697345ea368923cc798cad2102d
Add string cache and use it in cooked index

The cooked index needs to allocate names in some cases -- when
canonicalizing or when synthesizing Ada package names.  This process
currently uses a vector of unique_ptrs to manage the memory.

Another series I'm writing adds another spot where this allocation
must be done, and examining the result showed that certain names were
allocated multiple times.

To clean this up, this patch introduces a string cache object and
changes the cooked indexer to use it.  I considered using bcache here,
but bcache doesn't work as nicely with string_view -- because bcache
is fundamentally memory-based, a temporary copy of the contents must
be made to ensure that bcache can see the trailing \0.  Furthermore,
writing a custom class lets us avoid another copy when canonicalizing
C++ names.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
gdb/dwarf2/cooked-index.c
gdb/dwarf2/cooked-index.h
gdbsupport/string-set.h [new file with mode: 0644]