From a75cafbda23e6381420d940058eddb1a8de54b5a Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Wed, 14 Nov 2007 10:02:26 +0000 Subject: Speedup String#blank? and remove some overspecified tests. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8137 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/lib/active_support/core_ext/blank.rb | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'activesupport/lib/active_support') diff --git a/activesupport/lib/active_support/core_ext/blank.rb b/activesupport/lib/active_support/core_ext/blank.rb index d2a940f5b9..c4695816e2 100644 --- a/activesupport/lib/active_support/core_ext/blank.rb +++ b/activesupport/lib/active_support/core_ext/blank.rb @@ -7,13 +7,7 @@ class Object # to # if !address.blank? def blank? - if respond_to?(:empty?) && respond_to?(:strip) - empty? or strip.empty? - elsif respond_to?(:empty?) - empty? - else - !self - end + respond_to?(:empty?) ? empty? : !self end end @@ -45,7 +39,7 @@ end class String #:nodoc: def blank? - empty? || strip.empty? + self !~ /\S/ end end -- cgit v1.2.3