summaryrefslogtreecommitdiffhomepage
path: root/mrblib
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2018-09-22 23:05:52 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2018-09-26 23:09:48 +0900
commit8ffd4e47fb1c18088e554d31e8af88881517a201 (patch)
treea21688b128eb1f6fe5f3fb2007d359466c3956d7 /mrblib
parente8dcfe17454eb88f266f90cf31ca562e30378291 (diff)
downloadmruby-8ffd4e47fb1c18088e554d31e8af88881517a201.tar.gz
mruby-8ffd4e47fb1c18088e554d31e8af88881517a201.zip
Use `mrb_undef_value` for delete mark instead of shifting Hash entry table.
That means entry table should be compacted periodically by `sg_compact()`.
Diffstat (limited to 'mrblib')
-rw-r--r--mrblib/hash.rb12
1 files changed, 4 insertions, 8 deletions
diff --git a/mrblib/hash.rb b/mrblib/hash.rb
index 96029a230..eba92ba4a 100644
--- a/mrblib/hash.rb
+++ b/mrblib/hash.rb
@@ -55,10 +55,9 @@ class Hash
# ISO 15.2.13.4.8
def delete(key, &block)
if block && !self.has_key?(key)
- block.call(key)
- else
- self.__delete(key)
+ return block.call(key)
end
+ self.__delete(key)
end
##
@@ -335,11 +334,8 @@ class Hash
# h["AA"] #=> "b"
#
def rehash
- h = {}
- self.each{|k,v|
- h[k] = v
- }
- self.replace(h)
+ self.size
+ self
end
end