diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG index 2c70cecc2b5ccb119bf8d79ed88348e634248bfd..1fe697a227e674fd34cc76129a287d51bb27e3c8 100644 --- a/activesupport/CHANGELOG +++ b/activesupport/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Increased the speed of indifferent hash access by using Hash#default. #1436 [Nicholas Seckar] + * Added that " " is now also blank? (using strip if available) * Fixed Dependencies so all modules are able to load missing constants #1173 [Nicholas Seckar] @@ -137,4 +139,4 @@ * Added that Inflector now accepts Symbols and Classes by calling .to_s on the word supplied -* Added time unit extensions to Fixnum that'll return the period in seconds, like 2.days + 4.hours. \ No newline at end of file +* Added time unit extensions to Fixnum that'll return the period in seconds, like 2.days + 4.hours. diff --git a/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb b/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb index 91445610e27b0f742c2a9323155094c108c5e9ed..92653171f974313b697ab0adedd96a0a6f898171 100644 --- a/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb +++ b/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb @@ -8,16 +8,10 @@ def initialize(constructor = {}) super(constructor) end end - - alias_method :regular_reader, :[] unless method_defined?(:regular_reader) - - def [](key) - case key - when Symbol: regular_reader(key.to_s) || regular_reader(key) - when String: regular_reader(key) || regular_reader(key.to_sym) - else regular_reader(key) - end - end + + def default(key) + self[key.to_s] if key.is_a?(Symbol) + end alias_method :regular_writer, :[]= unless method_defined?(:regular_writer)