Benchmark:

```
puts(Benchmark.measure do
  10_000_000.times do
    ObjectSpace::WeakMap.new
  end
end)
```

Before:

```
2.568662   0.014001   2.582663 (  2.601743)
```

After:

```
2.025523   0.008676   2.034199 (  2.041760)
```
This commit is contained in:
Peter Zhu 2023-11-20 16:58:23 -05:00
Родитель 57fa69f26f
Коммит de337a312f
1 изменённых файлов: 2 добавлений и 3 удалений

Просмотреть файл

@ -88,7 +88,6 @@ wmap_free(void *ptr)
st_foreach(w->table, wmap_free_table_i, 0);
st_free_table(w->table);
xfree(w);
}
static size_t
@ -96,7 +95,7 @@ wmap_memsize(const void *ptr)
{
const struct weakmap *w = ptr;
size_t size = sizeof(*w);
size_t size = 0;
size += st_memsize(w->table);
/* The key and value of the table each take sizeof(VALUE) in size. */
size += st_table_size(w->table) * (2 * sizeof(VALUE));
@ -156,7 +155,7 @@ static const rb_data_type_t weakmap_type = {
wmap_memsize,
wmap_compact,
},
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_EMBEDDABLE
};
static int