diff options
author | Richard Schneeman <richard.schneeman+no-recruiters@gmail.com> | 2018-08-30 09:21:56 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-30 09:21:56 -0700 |
commit | 616afba436b16210c03c323f698e2c3603f16a9f (patch) | |
tree | 2ff0d1a6b03965dcb19b47d3d24921eb716c1277 | |
parent | 9f1d8f9e3d9d65f0888195073f0f8a56f7ab787d (diff) | |
parent | 897c377bad1cb5aa0c35e86c677e6b51cd3da2ac (diff) | |
download | rails-616afba436b16210c03c323f698e2c3603f16a9f.tar.gz rails-616afba436b16210c03c323f698e2c3603f16a9f.tar.bz2 rails-616afba436b16210c03c323f698e2c3603f16a9f.zip |
Merge pull request #33759 from schneems/schneems/move-variable-out-of-loop
Do not recompute length
-rw-r--r-- | activerecord/lib/active_record/result.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/result.rb b/activerecord/lib/active_record/result.rb index 7f1c2fd7eb..3b2556b1c8 100644 --- a/activerecord/lib/active_record/result.rb +++ b/activerecord/lib/active_record/result.rb @@ -140,6 +140,8 @@ module ActiveRecord # 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 @@ module ActiveRecord hash = {} index = 0 - length = columns.length - while index < length hash[columns[index]] = row[index] index += 1 |