[PATCH 4/9] Use htab_up in filename_seen_cache
Simon Marchi
simark@simark.ca
Mon Jul 20 01:41:05 GMT 2020
On 2020-07-18 1:29 p.m., Tom Tromey wrote:
> This changes filename_seen_cache to use htab_up, rather than explicit
> calls to htab_delete.
>
> gdb/ChangeLog
> 2020-07-18 Tom Tromey <tom@tromey.com>
>
> * filename-seen-cache.c (filename_seen_cache::filename_seen_cache)
> (filename_seen_cache::clear): Update.
> (~filename_seen_cache): Remove.
> (filename_seen_cache::seen): Update.
> * filename-seen-cache.h (class filename_seen_cache) <m_tab>: Now
> htab_up.
> <~filename_seen_cache>: Default.
> <traverse>: Update.
> ---
> gdb/ChangeLog | 11 +++++++++++
> gdb/filename-seen-cache.c | 17 +++++------------
> gdb/filename-seen-cache.h | 6 +++---
> 3 files changed, 19 insertions(+), 15 deletions(-)
>
> diff --git a/gdb/filename-seen-cache.c b/gdb/filename-seen-cache.c
> index f3905c0fb12..b0cda087cc0 100644
> --- a/gdb/filename-seen-cache.c
> +++ b/gdb/filename-seen-cache.c
> @@ -27,10 +27,10 @@
> /* filename_seen_cache constructor. */
>
> filename_seen_cache::filename_seen_cache ()
> + : m_tab (htab_create_alloc (INITIAL_FILENAME_SEEN_CACHE_SIZE,
> + filename_hash, filename_eq,
> + NULL, xcalloc, xfree))
> {
> - m_tab = htab_create_alloc (INITIAL_FILENAME_SEEN_CACHE_SIZE,
> - filename_hash, filename_eq,
> - NULL, xcalloc, xfree);
> }
>
> /* See filename-seen-cache.h. */
> @@ -38,14 +38,7 @@ filename_seen_cache::filename_seen_cache ()
> void
> filename_seen_cache::clear ()
> {
> - htab_empty (m_tab);
> -}
> -
> -/* See filename-seen-cache.h. */
> -
> -filename_seen_cache::~filename_seen_cache ()
> -{
> - htab_delete (m_tab);
> + htab_empty (m_tab.get ());
> }
>
> /* See filename-seen-cache.h. */
> @@ -56,7 +49,7 @@ filename_seen_cache::seen (const char *file)
> void **slot;
>
> /* Is FILE in tab? */
> - slot = htab_find_slot (m_tab, file, INSERT);
> + slot = htab_find_slot (m_tab.get (), file, INSERT);
> if (*slot != NULL)
> return true;
>
> diff --git a/gdb/filename-seen-cache.h b/gdb/filename-seen-cache.h
> index ee064c32565..ccc47694fff 100644
> --- a/gdb/filename-seen-cache.h
> +++ b/gdb/filename-seen-cache.h
> @@ -29,7 +29,7 @@ class filename_seen_cache
> {
> public:
> filename_seen_cache ();
> - ~filename_seen_cache ();
> + ~filename_seen_cache () = default;
Same as in the other patch, I don't really see the point to keep the explicitly defaulted destructor. Otherwise, LGTM.
Simon
More information about the Gdb-patches
mailing list