aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/blank.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-11-14 10:02:26 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-11-14 10:02:26 +0000
commita75cafbda23e6381420d940058eddb1a8de54b5a (patch)
treef37f9a779a87ad0ffe64c8090a9983199b5f6c7c /activesupport/lib/active_support/core_ext/blank.rb
parent696d140b6ce291262861ce7fc146de79461a8ecc (diff)
downloadrails-a75cafbda23e6381420d940058eddb1a8de54b5a.tar.gz
rails-a75cafbda23e6381420d940058eddb1a8de54b5a.tar.bz2
rails-a75cafbda23e6381420d940058eddb1a8de54b5a.zip
Speedup String#blank? and remove some overspecified tests.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8137 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib/active_support/core_ext/blank.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/blank.rb10
1 files changed, 2 insertions, 8 deletions
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