Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 4817

Show
Ignore:
Timestamp:
08/25/06 06:01:02 (2 years ago)
Author:
bitsweat
Message:

Use Array#assoc in ActiveSupport::OrderedHash.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activesupport/CHANGELOG

    r4787 r4817  
    11*SVN* 
     2 
     3* Use Array#assoc in ActiveSupport::OrderedHash. [Mauricio Fernandez] 
    24 
    35* Greatly increased performance of String.to_json, which speeds up RJS considerably on large pages, fixes #3473 [Shugo Maeda] 
  • trunk/activesupport/lib/active_support/ordered_options.rb

    r4411 r4817  
    33  class OrderedHash < Array #:nodoc: 
    44    def []=(key, value) 
    5       if pair = find_pair(key) 
     5      if pair = assoc(key) 
    66        pair.pop 
    77        pair << value 
     
    1212 
    1313    def [](key) 
    14       pair = find_pair(key) 
     14      pair = assoc(key) 
    1515      pair ? pair.last : nil 
    1616    end 
     
    2323      collect { |key, value| value } 
    2424    end 
    25  
    26     private 
    27       def find_pair(key) 
    28         self.each { |i| return i if i.first == key } 
    29         return false 
    30       end 
    3125  end 
    3226end