From 1a0853c41f0d7a7ac5708fdc5f14f2aeba4bcbe0 Mon Sep 17 00:00:00 2001 From: ojab Date: Sun, 12 Apr 2015 20:37:46 +0000 Subject: Speedup String#squish --- activesupport/lib/active_support/core_ext/string/filters.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/core_ext/string/filters.rb b/activesupport/lib/active_support/core_ext/string/filters.rb index 7461d03acc..375ec1aef8 100644 --- a/activesupport/lib/active_support/core_ext/string/filters.rb +++ b/activesupport/lib/active_support/core_ext/string/filters.rb @@ -17,9 +17,8 @@ class String # str.squish! # => "foo bar boo" # str # => "foo bar boo" def squish! - gsub!(/\A[[:space:]]+/, '') - gsub!(/[[:space:]]+\z/, '') gsub!(/[[:space:]]+/, ' ') + strip! self end -- cgit v1.2.3