simpler implementation of Hash#empty?

This commit is contained in:
Yukihiro Matsumoto
2012-06-02 23:52:32 +09:00
parent 8d0cc57a43
commit ecbaf9cd99
+4 -4
View File
@@ -819,12 +819,12 @@ mrb_hash_empty_p(mrb_state *mrb, mrb_value self)
{
khash_t(ht) *h = RHASH_TBL(self);
khiter_t k;
if (h) {
for (k = kh_begin(h); k != kh_end(h); k++)
if (kh_exist(h, k))
return mrb_false_value();
if (kh_size(h) == 0)
return mrb_true_value();
}
return mrb_true_value();
return mrb_false_value();
}
/* 15.2.13.4.11 */