specify allocating array size for Hash#values

This commit is contained in:
Yukihiro Matsumoto
2012-05-30 16:12:32 +09:00
parent 0de8ffb0de
commit a4a48e3da1
2 changed files with 2 additions and 1 deletions
+1 -1
View File
@@ -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++) {
+1
View File
@@ -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