提交 3ce3c219 编写于 作者: A Aaron Patterson

no use for set, no need to to_ary, reduce extra objects

上级 6e14feb9
require 'set'
require 'active_support/core_ext/array/wrap' require 'active_support/core_ext/array/wrap'
module ActiveRecord module ActiveRecord
...@@ -75,7 +74,7 @@ def first(*args) ...@@ -75,7 +74,7 @@ def first(*args)
find(:first, *args) find(:first, *args)
else else
load_target unless loaded? load_target unless loaded?
args = args[1..-1] if args.first.kind_of?(Hash) && args.first.empty? args.shift if args.first.kind_of?(Hash) && args.first.empty?
@target.first(*args) @target.first(*args)
end end
end end
...@@ -93,7 +92,7 @@ def last(*args) ...@@ -93,7 +92,7 @@ def last(*args)
def to_ary def to_ary
load_target load_target
if @target.is_a?(Array) if @target.is_a?(Array)
@target.to_ary @target
else else
Array.wrap(@target) Array.wrap(@target)
end end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册