From 145ead95e539d5c3136e0e3bbf6b2662b46f9cdd Mon Sep 17 00:00:00 2001 From: Viktar Basharymau Date: Sat, 2 Jan 2016 21:46:05 +0300 Subject: [PATCH] Use .flat_map{} instead of .map{}.flatten In this particular case, they are semantically equivalent, but flat_map is shorter and faster. --- lib/chewy/type/import.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/chewy/type/import.rb b/lib/chewy/type/import.rb index 72c2507de..7a369fed2 100644 --- a/lib/chewy/type/import.rb +++ b/lib/chewy/type/import.rb @@ -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