mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
specify allocating array size for Hash#values
This commit is contained in:
+1
-1
@@ -1037,7 +1037,7 @@ mrb_hash_values(mrb_state *mrb, mrb_value hash)
|
||||
{
|
||||
khash_t(ht) *h = RHASH_TBL(hash);
|
||||
khiter_t k;
|
||||
mrb_value ary = mrb_ary_new(mrb);
|
||||
mrb_value ary = mrb_ary_new_capa(mrb, kh_size(h));
|
||||
|
||||
if (!h) return ary;
|
||||
for (k = kh_begin(h); k != kh_end(h); k++) {
|
||||
|
||||
@@ -222,5 +222,6 @@ end
|
||||
assert('Hash#values', '15.2.13.4.28') do
|
||||
a = { 'abc_key' => 'abc_value' }
|
||||
|
||||
p a.values
|
||||
a.values == ['abc_value']
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user