Skip to content

Commit

Permalink
Use yield instead of block.call
Browse files Browse the repository at this point in the history
Reverts the change motivated by https://bugs.ruby-lang.org/issues/11451,
see also #189.

The underlying issue was fixed in r52717, which is in Ruby
2.2.5. This requires some discussion about whether support for earlier
Ruby 2.2.x releases can be dropped at this stage.
  • Loading branch information
Tom Johnson committed Jun 30, 2016
1 parent 43d814e commit bf6ffbf
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions lib/hamster/trie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,7 @@ def key?(key)

# Calls <tt>block</tt> once for each entry in the trie, passing the key-value pair as parameters.
def each(&block)
# TODO: Using block.call here is slower than using yield by 5-10%, but
# the latter segfaults on ruby 2.2 and above. Once that is fixed and
# broken versions are sufficiently old, we should revert back to yield
# with a warning that the broken versions are unsupported.
#
# For more context:
# * https://bugs.ruby-lang.org/issues/11451
# * https://github.com/hamstergem/hamster/issues/189
@entries.each { |entry| block.call(entry) if entry }
@entries.each { |entry| yield(entry) if entry }
@children.each do |child|
child.each(&block) if child
end
Expand Down

0 comments on commit bf6ffbf

Please sign in to comment.