aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorManfred Stienstra <manfred@fngtps.com>2009-11-02 21:06:12 +0100
committerManfred Stienstra <manfred@fngtps.com>2009-11-04 10:12:06 +0100
commit62a022891b5f12284205920a03a3cbbe5b8ecd27 (patch)
treec1aa39982fa4052c7b188c62e5309f9396a944f6 /activesupport
parent935bd0fef8e26f4ec65fe411a1d29942493f8d46 (diff)
downloadrails-62a022891b5f12284205920a03a3cbbe5b8ecd27.tar.gz
rails-62a022891b5f12284205920a03a3cbbe5b8ecd27.tar.bz2
rails-62a022891b5f12284205920a03a3cbbe5b8ecd27.zip
Improve performance of Multibyte::Utils.
Replace explicit for-loops by faster enumeration methods. [#3158 state:committed]
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/multibyte/utils.rb13
1 files changed, 6 insertions, 7 deletions
diff --git a/activesupport/lib/active_support/multibyte/utils.rb b/activesupport/lib/active_support/multibyte/utils.rb
index 8e47763d39..b243df46d8 100644
--- a/activesupport/lib/active_support/multibyte/utils.rb
+++ b/activesupport/lib/active_support/multibyte/utils.rb
@@ -26,11 +26,11 @@ module ActiveSupport #:nodoc:
else
def self.verify(string)
if expression = valid_character
- for c in string.split(//)
- return false unless expression.match(c)
- end
+ # Splits the string on character boundaries, which are determined based on $KCODE.
+ string.split(//).all? { |c| expression.match(c) }
+ else
+ true
end
- true
end
end
@@ -49,9 +49,8 @@ module ActiveSupport #:nodoc:
else
def self.clean(string)
if expression = valid_character
- stripped = []; for c in string.split(//)
- stripped << c if expression.match(c)
- end; stripped.join
+ # Splits the string on character boundaries, which are determined based on $KCODE.
+ string.split(//).grep(expression).join
else
string
end