diff options
author | Aaron Lasseigne <aaron.lasseigne@gmail.com> | 2015-08-07 16:37:59 -0500 |
---|---|---|
committer | Aaron Lasseigne <aaron.lasseigne@gmail.com> | 2015-08-08 11:54:09 -0500 |
commit | 725f9bf3e284cedf09bdd26712cfa5c7f39a08e0 (patch) | |
tree | 6874b32587001aa5fdb2bf20584815c3c03147f1 /activesupport/lib | |
parent | 9645820bdb4d8cd131c855a243d2fbc636a11908 (diff) | |
download | rails-725f9bf3e284cedf09bdd26712cfa5c7f39a08e0.tar.gz rails-725f9bf3e284cedf09bdd26712cfa5c7f39a08e0.tar.bz2 rails-725f9bf3e284cedf09bdd26712cfa5c7f39a08e0.zip |
replace each with each_key when only the key is needed
Using each_key is faster and more intention revealing.
Calculating -------------------------------------
each 31.378k i/100ms
each_key 33.790k i/100ms
-------------------------------------------------
each 450.225k (± 7.0%) i/s - 2.259M
each_key 494.459k (± 6.3%) i/s - 2.467M
Comparison:
each_key: 494459.4 i/s
each: 450225.1 i/s - 1.10x slower
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/multibyte/unicode.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/multibyte/unicode.rb b/activesupport/lib/active_support/multibyte/unicode.rb index 4de7fa4e4b..b6c991a287 100644 --- a/activesupport/lib/active_support/multibyte/unicode.rb +++ b/activesupport/lib/active_support/multibyte/unicode.rb @@ -338,7 +338,7 @@ module ActiveSupport end # Redefine the === method so we can write shorter rules for grapheme cluster breaks - @boundary.each do |k,_| + @boundary.each_key do |k| @boundary[k].instance_eval do def ===(other) detect { |i| i === other } ? true : false |