Permalink
Browse files

Boolean type casting creates fewer objects

  • Loading branch information...
1 parent f82bd31 commit 11252e35b1756b025d8778c151f9f9a24057d1b1 @jeremy jeremy committed Jul 9, 2008
@@ -138,7 +138,7 @@ def value_to_boolean(value)
if value == true || value == false
value
else
- %w(true t 1).include?(value.to_s.downcase)
+ !(value.to_s !~ /\A(?:1|t|true)\Z/i)
end
end

1 comment on commit 11252e3

Contributor

tarmo commented on 11252e3 Jul 11, 2008

It’s roughly 25-50% faster depending on what the type or contents of value is. Try this: http://pastie.org/231896

Please sign in to comment.