diff mbox

[03/13] Make ggc_cached_hasher inherit from ggc_hasher

Message ID 87381s2fy6.fsf@e105548-lin.cambridge.arm.com
State New
Headers show

Commit Message

Richard Sandiford June 16, 2015, 8:52 a.m. UTC
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.

Comments

Jeff Law June 23, 2015, 8:55 p.m. UTC | #1
On 06/16/2015 02:52 AM, Richard Sandiford wrote:
> 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.
OK.
jeff
diff mbox

Patch

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)
   {