aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2016-07-22 00:13:41 +0200
committerXavier Noria <fxn@hashref.com>2016-07-22 00:16:24 +0200
commit929a6500806fe671d9ac0002da8537bf26b8f25d (patch)
tree8366364ca94d6357fa006661c85c3e05cf77de90 /activesupport
parent575dbeeefcaafeb566afc07cdd8b55603b698d9f (diff)
downloadrails-929a6500806fe671d9ac0002da8537bf26b8f25d.tar.gz
rails-929a6500806fe671d9ac0002da8537bf26b8f25d.tar.bz2
rails-929a6500806fe671d9ac0002da8537bf26b8f25d.zip
performance boost for String#blank? in Ruby 2.4
Some casual benchmarks showed a 2x factor. All credit goes to @nurse.
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/core_ext/object/blank.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/object/blank.rb b/activesupport/lib/active_support/core_ext/object/blank.rb
index cb74bad73e..08fb3d5420 100644
--- a/activesupport/lib/active_support/core_ext/object/blank.rb
+++ b/activesupport/lib/active_support/core_ext/object/blank.rb
@@ -115,7 +115,7 @@ class String
# The regexp that matches blank strings is expensive. For the case of empty
# strings we can speed up this method (~3.5x) with an empty? call. The
# penalty for the rest of strings is marginal.
- empty? || BLANK_RE === self
+ empty? || BLANK_RE.match?(self)
end
end