summaryrefslogtreecommitdiffhomepage
path: root/src/hash.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2019-02-11 15:19:20 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2019-02-11 15:20:34 +0900
commitef93ff64054f2aa7e4451387fb768fe2307247a9 (patch)
tree3a837cae72dc65a02df29df0951bba5e0d300d0d /src/hash.c
parent639f6e2799f33a7889c4ca48ae0e314e67214dfc (diff)
downloadmruby-ef93ff64054f2aa7e4451387fb768fe2307247a9.tar.gz
mruby-ef93ff64054f2aa7e4451387fb768fe2307247a9.zip
Should not copy keys&values when a hash table is empty; fix #4270
Diffstat (limited to 'src/hash.c')
-rw-r--r--src/hash.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/hash.c b/src/hash.c
index 6b92344c3..fd963c3de 100644
--- a/src/hash.c
+++ b/src/hash.c
@@ -536,6 +536,7 @@ ht_copy(mrb_state *mrb, htable *t)
seg = t->rootseg;
t2 = ht_new(mrb);
+ if (t->size == 0) return t2;
while (seg) {
for (i=0; i<seg->size; i++) {