summaryrefslogtreecommitdiff
path: root/lib/ohai/plugins/linux/network.rb
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2021-04-21 20:17:01 -0700
committerTim Smith <tsmith84@gmail.com>2021-04-21 20:18:30 -0700
commite2dd316c2380bd2a06c8bf928357169e089a401e (patch)
tree9b12cf8e0be3585880347b8c64fee1e55584a0db /lib/ohai/plugins/linux/network.rb
parente48813786a6dbb80d83cb33de3876d48b6518f28 (diff)
downloadohai-perf.tar.gz
Use filter_map where we canperf
We only support Ruby 2.7+ and this takes less memory Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'lib/ohai/plugins/linux/network.rb')
-rw-r--r--lib/ohai/plugins/linux/network.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/ohai/plugins/linux/network.rb b/lib/ohai/plugins/linux/network.rb
index 713b9c16..80168e39 100644
--- a/lib/ohai/plugins/linux/network.rb
+++ b/lib/ohai/plugins/linux/network.rb
@@ -141,13 +141,13 @@ Ohai.plugin(:Network) do
# using a temporary var to hold routes and their interface name
def parse_routes(family, iface)
- iface.collect do |i, iv|
+ iface.filter_map do |i, iv|
next unless iv[:routes]
- iv[:routes].collect do |r|
+ iv[:routes].filter_map do |r|
r.merge(dev: i) if r[:family] == family[:name]
- end.compact # @todo: when we drop ruby 2.6 this should be a filter_map
- end.compact.flatten # @todo: when we drop ruby 2.6 this should be a filter_map
+ end
+ end.flatten
end
# determine layer 1 details for the interface using ethtool