Skip to content

Commit

Permalink
Revert "Hash#update() vs Hash#[]=" - issues with tests and high poten…
Browse files Browse the repository at this point in the history
…tial for naming conflicts with AR methods

This reverts commit dc7a28c.
  • Loading branch information
DamirSvrtan committed Jan 25, 2024
1 parent fb0f02c commit 5c113a9
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 50 deletions.
1 change: 0 additions & 1 deletion .fasterer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ speedups:
fetch_with_argument_vs_block: true
keys_each_vs_each_key: true
hash_merge_bang_vs_hash_brackets: true
hash_update_vs_hash_brackets: true
block_vs_symbol_to_proc: true
proc_call_vs_yield: true
gsub_vs_tr: true
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ speedups:
fetch_with_argument_vs_block: true
keys_each_vs_each_key: true
hash_merge_bang_vs_hash_brackets: true
hash_update_vs_hash_brackets: true
block_vs_symbol_to_proc: true
proc_call_vs_yield: true
gsub_vs_tr: true
Expand Down
3 changes: 0 additions & 3 deletions lib/fasterer/offense.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ def explanation
hash_merge_bang_vs_hash_brackets:
'Hash#merge! with one argument is slower than Hash#[]',

hash_update_vs_hash_brackets:
'Hash#update with one argument is slower than Hash#[]',

block_vs_symbol_to_proc:
'Calling argumentless methods within blocks is slower than using symbol to proc',

Expand Down
13 changes: 0 additions & 13 deletions lib/fasterer/scanners/method_call_scanner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ def check_offense
check_fetch_offense
when :merge!
check_merge_bang_offense
when :update
check_update_offense
when :last
check_last_offense
when :include?
Expand Down Expand Up @@ -154,17 +152,6 @@ def check_merge_bang_offense
end
end

def check_update_offense
return unless method_call.arguments.count == 1

first_argument = method_call.arguments.first
return unless first_argument.type == :hash

if first_argument.element.drop(1).count == 2 # each key and value is an item by itself.
add_offense(:hash_update_vs_hash_brackets)
end
end

def check_last_offense
return method_call unless method_call.receiver.is_a?(MethodCall)

Expand Down
11 changes: 0 additions & 11 deletions spec/lib/fasterer/analyzer/17_hash_update_vs_hash_brackets_spec.rb

This file was deleted.

21 changes: 0 additions & 21 deletions spec/support/analyzer/17_hash_update_vs_hash_brackets.rb

This file was deleted.

0 comments on commit 5c113a9

Please sign in to comment.