Skip to content

Files

Latest commit

 

History

History
32 lines (24 loc) · 792 Bytes

Performance-RedundantBlockCall.md

File metadata and controls

32 lines (24 loc) · 792 Bytes

Pattern: Redundant block call

Issue: -

Description

This rule identifies the use of a &block parameter and block.call where yield would do just as well. In MRI Ruby, block arguments are converted to Procs, which incurs a heap allocation.

Examples

# bad
def method(&block)
  block.call
end
def another(&func)
  func.call 1, 2, 3
end

# good
def method
  yield
end
def another
  yield 1, 2, 3
end

Further Reading