Skip to content

Commit

Permalink
Merge pull request #428 from crystal-ameba/revert-incorrect-excessive…
Browse files Browse the repository at this point in the history
…-allocations-condition

Revert "Fix `Performance/ExcessiveAllocations` to exclude `each` call…
  • Loading branch information
Sija authored Nov 18, 2023
2 parents 5e70ae4 + 82e0e53 commit 9f9d5fa
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
1 change: 0 additions & 1 deletion spec/ameba/rule/performance/excessive_allocations_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module Ameba::Rule::Performance
describe ExcessiveAllocations do
it "passes if there is no potential performance improvements" do
expect_no_issues subject, <<-CRYSTAL
"Alice".chars.each
"Alice".chars.each(arg) { |c| puts c }
"Alice".chars(arg).each { |c| puts c }
"Alice\nBob".lines.each(arg) { |l| puts l }
Expand Down
2 changes: 1 addition & 1 deletion src/ameba/rule/performance/excessive_allocations.cr
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ module Ameba::Rule::Performance
end

def test(source, node : Crystal::Call)
return unless node.name == "each" && node.args.empty? && node.block
return unless node.name == "each" && node.args.empty?
return unless (obj = node.obj).is_a?(Crystal::Call)
return unless obj.args.empty? && obj.block.nil?
return unless method = call_names[obj.name]?
Expand Down

0 comments on commit 9f9d5fa

Please sign in to comment.