Skip to content

Commit

Permalink
Use faster === for regexp matching
Browse files Browse the repository at this point in the history
We do not rely on the result of the matching, or any part of it, just
whether it matches or not, so === is preferable as it's slightly faster
by not creating extra matching objects.

Also remove the condition for nil as it responds to === and always
returns false.

    >> nil === 'zomg'
    => false
  • Loading branch information
carlosantoniodasilva committed Feb 24, 2017
1 parent 30908a7 commit b2eba0e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rollbar/scrubbers/params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def scrub(params, options)
return scrub_array(params, options) if params.is_a?(Array)

params.to_hash.inject({}) do |result, (key, value)|
if fields_regex && fields_regex =~ Rollbar::Encoding.encode(key).to_s
if fields_regex === Rollbar::Encoding.encode(key).to_s
result[key] = scrub_value(value)
elsif value.is_a?(Hash)
result[key] = scrub(value, options)
Expand Down

0 comments on commit b2eba0e

Please sign in to comment.