Use Array#assoc in ActiveSupport::OrderedHash.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4817 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
ee2397036f
commit
4dc464c1df
|
@ -1,5 +1,7 @@
|
||||||
*SVN*
|
*SVN*
|
||||||
|
|
||||||
|
* Use Array#assoc in ActiveSupport::OrderedHash. [Mauricio Fernandez]
|
||||||
|
|
||||||
* Greatly increased performance of String.to_json, which speeds up RJS considerably on large pages, fixes #3473 [Shugo Maeda]
|
* Greatly increased performance of String.to_json, which speeds up RJS considerably on large pages, fixes #3473 [Shugo Maeda]
|
||||||
|
|
||||||
* Detect missing_constants calls from removed modules and fail accordingly. [Nicholas Seckar]
|
* Detect missing_constants calls from removed modules and fail accordingly. [Nicholas Seckar]
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
module ActiveSupport
|
module ActiveSupport
|
||||||
class OrderedHash < Array #:nodoc:
|
class OrderedHash < Array #:nodoc:
|
||||||
def []=(key, value)
|
def []=(key, value)
|
||||||
if pair = find_pair(key)
|
if pair = assoc(key)
|
||||||
pair.pop
|
pair.pop
|
||||||
pair << value
|
pair << value
|
||||||
else
|
else
|
||||||
|
@ -11,7 +11,7 @@ module ActiveSupport
|
||||||
end
|
end
|
||||||
|
|
||||||
def [](key)
|
def [](key)
|
||||||
pair = find_pair(key)
|
pair = assoc(key)
|
||||||
pair ? pair.last : nil
|
pair ? pair.last : nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -22,12 +22,6 @@ module ActiveSupport
|
||||||
def values
|
def values
|
||||||
collect { |key, value| value }
|
collect { |key, value| value }
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
def find_pair(key)
|
|
||||||
self.each { |i| return i if i.first == key }
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue