提交 677d77d4 编写于 作者: A Aaron Patterson

PERF: this hash only ever has one value, also avoid inject

上级 60f8668d
......@@ -206,10 +206,12 @@ def locked; [] end
private
def matching_attributes(attribute)
(@matching_attributes ||= attributes.inject({}) do |hash, a|
(hash[a.is_a?(Value) ? a.value : a.root] ||= []) << a
hash
end)[attribute.root] || []
unless @matching_attributes
@matching_attributes = Hash[attributes.map do |a|
[a.root, a]
end]
end
[@matching_attributes[attribute.root]] || []
end
def has_attribute?(attribute)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册