提交 897c377b 编写于 作者: S schneems

Do not recompute length

We can get a speed gain by moving the length calculation and assignment out of the loop.
上级 cc81cd35
......@@ -140,6 +140,8 @@ def hash_rows
# We freeze the strings to prevent them getting duped when
# used as keys in ActiveRecord::Base's @attributes hash
columns = @columns.map(&:-@)
length = columns.length
@rows.map { |row|
# In the past we used Hash[columns.zip(row)]
# though elegant, the verbose way is much more efficient
......@@ -148,8 +150,6 @@ def hash_rows
hash = {}
index = 0
length = columns.length
while index < length
hash[columns[index]] = row[index]
index += 1
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册