ruby-changes:58305
From: Nobuyoshi <ko1@a...>
Date: Fri, 18 Oct 2019 14:57:35 +0900 (JST)
Subject: [ruby-changes:58305] ce7942361d (master): Use identhash as WeakMap
https://git.ruby-lang.org/ruby.git/commit/?id=ce7942361d From ce7942361d1f1f9a1ca958b6979a432da2014683 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Fri, 18 Oct 2019 02:51:15 +0900 Subject: Use identhash as WeakMap As ObjectSpace::WeakMap allows FLONUM as a key, needs the special deal for its hash. [Feature #16035] diff --git a/gc.c b/gc.c index 8900279..b95094b 100644 --- a/gc.c +++ b/gc.c @@ -10493,13 +10493,15 @@ static const rb_data_type_t weakmap_type = { https://github.com/ruby/ruby/blob/trunk/gc.c#L10493 0, 0, RUBY_TYPED_FREE_IMMEDIATELY }; +extern const struct st_hash_type rb_hashtype_ident; + static VALUE wmap_allocate(VALUE klass) { struct weakmap *w; VALUE obj = TypedData_Make_Struct(klass, struct weakmap, &weakmap_type, w); - w->obj2wmap = st_init_numtable(); - w->wmap2obj = st_init_numtable(); + w->obj2wmap = st_init_table(&rb_hashtype_ident); + w->wmap2obj = st_init_table(&rb_hashtype_ident); w->final = rb_obj_method(obj, ID2SYM(rb_intern("finalize"))); return obj; } diff --git a/hash.c b/hash.c index 9b5f978..b73ade7 100644 --- a/hash.c +++ b/hash.c @@ -330,7 +330,8 @@ rb_ident_hash(st_data_t n) https://github.com/ruby/ruby/blob/trunk/hash.c#L330 return (st_index_t)st_index_hash((st_index_t)n); } -static const struct st_hash_type identhash = { +#define identhash rb_hashtype_ident +const struct st_hash_type rb_hashtype_ident = { rb_ident_cmp, rb_ident_hash, }; -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/