Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH v2] Add string cache and use it in cooked index
Date: Mon, 10 Mar 2025 15:45:56 -0400	[thread overview]
Message-ID: <8c3b216e-5c62-42ce-8983-ef8e5df29bd5@simark.ca> (raw)
In-Reply-To: <20250310193815.2425344-1-tom@tromey.com>

On 3/10/25 3:38 PM, Tom Tromey wrote:
> 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.

Thanks, LGTM.

Approved-By: Simon Marchi <simon.marchi@efficios.com>

I was thinking that maybe this woud actually be a good use case for an
obstack, since free'ing would probably be faster than freeing the
strings individually.  But we have cases where the caller passes a
unique_xmalloc_ptr, in two cases we'd need an extra copy into the
obstack.

Simon

  reply	other threads:[~2025-03-10 19:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-10 19:38 Tom Tromey
2025-03-10 19:45 ` Simon Marchi [this message]
2025-03-10 19:51   ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8c3b216e-5c62-42ce-8983-ef8e5df29bd5@simark.ca \
    --to=simark@simark.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox