Skip to content

Commit

Permalink
Use .flat_map{} instead of .map{}.flatten
Browse files Browse the repository at this point in the history
In this particular case, they are semantically equivalent,
but flat_map is shorter and faster.
  • Loading branch information
DNNX committed Jan 2, 2016
1 parent d7dbaa9 commit 145ead9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/chewy/type/import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def bulk_body(action_objects, indexed_objects = nil)
action_objects.flat_map do |action, objects|
method = "#{action}_bulk_entry"
crutches = Chewy::Type::Crutch::Crutches.new self, objects
objects.map { |object| send(method, object, indexed_objects, crutches) }.flatten
objects.flat_map { |object| send(method, object, indexed_objects, crutches) }
end
end

Expand Down

0 comments on commit 145ead9

Please sign in to comment.