dumping ground for random patches and texts
 help / color / mirror / Atom feed
* [PATCH] array.c (ary_recycle_hash): use rb_gc_force_recycle
@ 2017-02-13  0:47 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2017-02-13  0:47 UTC (permalink / raw)
  To: spew

Hidden objects (RBASIC_CLASS(hash) == 0) can never become
visible to other threads or signal handlers via
ObjectSpace.each_object or similar means.  Thus it is safe to
forcibly recycle the object slot for future use, here.
---
 array.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/array.c b/array.c
index f170a942ac..e970ca3787 100644
--- a/array.c
+++ b/array.c
@@ -4095,12 +4095,12 @@ ary_make_hash_by(VALUE ary)
 static inline void
 ary_recycle_hash(VALUE hash)
 {
+    assert(RBASIC_CLASS(hash) == 0);
     if (RHASH(hash)->ntbl) {
 	st_table *tbl = RHASH(hash)->ntbl;
-	RHASH(hash)->ntbl = 0;
 	st_free_table(tbl);
     }
-    RB_GC_GUARD(hash);
+    rb_gc_force_recycle(hash);
 }
 
 /*
-- 
EW


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-02-13  0:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-13  0:47 [PATCH] array.c (ary_recycle_hash): use rb_gc_force_recycle Eric Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).