This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[03/13] Make ggc_cached_hasher inherit from ggc_hasher
- From: Richard Sandiford <richard dot sandiford at arm dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 16 Jun 2015 09:52:17 +0100
- Subject: [03/13] Make ggc_cached_hasher inherit from ggc_hasher
- Authentication-results: sourceware.org; auth=none
- References: <87fv5s2gej dot fsf at e105548-lin dot cambridge dot arm dot com>
Most of ggc_cache_hasher is duplicated from ggc_hasher. This patch
gets the same functionality via inheritance. It also brings the
ggc_hasher functions in line with ggc_cache_hasher by making remove()
and ggc_mx() take references rather than pointers. This seems more
consistent with the idea that elements don't need to be pointers and
could be some gc-ed structure instead.
gcc/
* hash-traits.h (ggc_hasher::remove): Take a reference parameter.
(ggc_hasher::ggc_mx): Likewise.
(ggc_cache_hasher): Inherit from ggc_hasher. Remove definitions
that duplicate ggc_hasher ones.
Index: gcc/hash-traits.h
===================================================================
--- gcc/hash-traits.h 2015-06-16 09:48:19.893867495 +0100
+++ gcc/hash-traits.h 2015-06-16 09:48:42.361611494 +0100
@@ -96,10 +96,10 @@ struct ggc_hasher
typedef T value_type;
typedef T compare_type;
- static void remove (T) {}
+ static void remove (T &) {}
static void
- ggc_mx (T p)
+ ggc_mx (T &p)
{
extern void gt_ggc_mx (T &);
gt_ggc_mx (p);
@@ -122,30 +122,11 @@ struct ggc_hasher
/* Hasher for cache entry in gc memory. */
template<typename T>
-struct ggc_cache_hasher
+struct ggc_cache_hasher : ggc_hasher<T>
{
- typedef T value_type;
- typedef T compare_type;
-
- static void remove (T &) {}
-
/* Entries are weakly held because this is for caches. */
-
static void ggc_mx (T &) {}
- static void
- pch_nx (T &p)
- {
- extern void gt_pch_nx (T &);
- gt_pch_nx (p);
- }
-
- static void
- pch_nx (T &p, gt_pointer_operator op, void *cookie)
- {
- op (&p, cookie);
- }
-
static int
keep_cache_entry (T &e)
{