提交 4fc493ff 编写于 作者: X Xavier Noria

Merge pull request #17658 from SamSaffron/optimise_memory

PERF: stop allocating the string "id" over and over
......@@ -76,12 +76,14 @@ def #{temp_method}
end
end
ID = 'id'.freeze
# Returns the value of the attribute identified by <tt>attr_name</tt> after
# it has been typecast (for example, "2004-12-12" in a date column is cast
# to a date object, like Date.new(2004, 12, 12)).
def read_attribute(attr_name, &block)
name = attr_name.to_s
name = self.class.primary_key if name == 'id'
name = self.class.primary_key if name == ID
@attributes.fetch_value(name, &block)
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册