2 Commits

Author SHA1 Message Date
Tom Tromey
b6cc4ef6d2 Use correct types in string-set.h
My earlier patch to introduce string-set.h used the wrong type in the
hash functions.  This patch fixes the error.
2025-03-12 14:23:50 -06:00
Tom Tromey
2609ee6f19 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>
2025-03-10 15:05:34 -06:00