Permalink
Browse files

Merge pull request #12091 from rywall/pluck-optimization

[Perf] Don't use Enumerable#next in pluck since it is very slow
  • Loading branch information...
2 parents 92c35ad + 8467be9 commit 6617437ef26c27e8be99d5d086f810c5c4aaf6a0 @josevalim josevalim committed Aug 31, 2013
Showing with 1 addition and 2 deletions.
  1. +1 −2 activerecord/lib/active_record/relation/calculations.rb
@@ -161,8 +161,7 @@ def pluck(*column_names)
result = result.map do |attributes|
values = klass.initialize_attributes(attributes).values
- iter = columns.each
- values.map { |value| iter.next.type_cast value }
+ columns.zip(values).map { |column, value| column.type_cast value }
end
columns.one? ? result.map!(&:first) : result
end

0 comments on commit 6617437

Please sign in to comment.