#ruby's #flat_map is much faster than combining #map and #flatten.

require 'benchmark'

arr = 1_000.times.map { (1..100).to_a }

Benchmark.bm 10 do |x|
  x.report('#flatten') { arr.map { |x| x << 1001 }.flatten(1) }
  x.report('#flat_map') { arr.flat_map { |x| x << 1001 } }
end

The results

# $ ruby flat_map.rb
#                 user     system      total        real
# #flatten     0.010000   0.000000   0.010000 (  0.024426)
# #flat_map    0.000000   0.000000   0.000000 (  0.001466)

# $ ruby flat_map.rb
#                 user     system      total        real
# #flatten     0.010000   0.000000   0.010000 (  0.031431)
# #flat_map    0.010000   0.000000   0.010000 (  0.001546)