Permalink
Browse files

Revert "Make Hash#each_item private"

This reverts commit ad0ff8d.

As @brixen and @evanphx suggested on #1730 we should use #each_item
where it was used before.
  • Loading branch information...
1 parent 18965ca commit bba2d2e2492df74568d0a8387977173612c46cda @carlosgaldino committed Jun 24, 2012
Showing with 15 additions and 14 deletions.
  1. +7 −6 kernel/common/hash18.rb
  2. +8 −8 kernel/common/hash19.rb
@@ -158,7 +158,6 @@ def each_item
idx += 1
end
end
- private :each_item
def each
return to_enum(:each) unless block_given?
@@ -236,16 +235,18 @@ def merge!(other)
other = Rubinius::Type.coerce_to other, Hash, :to_hash
if block_given?
- other.each do |key, value|
+ other.each_item do |item|
+ key = item.key
if key? key
- __store__ key, yield(key, self[key], value)
+ __store__ key, yield(key, self[key], item.value)
else
- __store__ key, value
+ __store__ key, item.value
end
end
else
- other.each do |key, value|
- __store__ key, value
+ other.each_item do |item|
+ key = item.key
+ __store__ key, item.value
end
end
self
@@ -232,7 +232,6 @@ def each_item
item = item.next
end
end
- private :each_item
def each
return to_enum(:each) unless block_given?
@@ -317,16 +316,17 @@ def merge!(other)
other = Rubinius::Type.coerce_to other, Hash, :to_hash
if block_given?
- other.each do |key, value|
+ other.each_item do |item|
+ key = item.key
if key? key
- __store__ key, yield(key, self[key], value)
+ __store__ key, yield(key, self[key], item.value)
else
- __store__ key, value
+ __store__ key, item.value
end
end
else
- other.each do |key, value|
- __store__ key, value
+ other.each_item do |item|
+ __store__ item.key, item.value
end
end
self
@@ -400,8 +400,8 @@ def replace(other)
@state = State.new
@state.compare_by_identity if other.compare_by_identity?
- other.each do |key, value|
- __store__ key, value
+ other.each_item do |item|
+ __store__ item.key, item.value
end
@default = other.default

0 comments on commit bba2d2e

Please sign in to comment.