-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Follow up on #54 "Fog google upgrade (to 1.3.3)" code cleanup #59
Conversation
@@ -180,7 +180,7 @@ def get_cloud_networks | |||
|
|||
def subnetworks | |||
unless @subnetworks | |||
@subnetworks = @connection.list_aggregated_subnetworks.to_h[:items].flat_map { |_, v| v[:subnetworks] } | |||
@subnetworks = @connection.list_aggregated_subnetworks.to_h[:items].values.flat_map { |v| v[:subnetworks] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@agrare, I couldn't do here what you've suggested. The :subnetworks
is not an method but a key in Hash so we can't be calling it like:
@connection.list_aggregated_subnetworks.to_h[:items].values.flat_map(&:subnetworks)
I've tried also this:
@connection.list_aggregated_subnetworks.to_h[:items].values.pluck(:subnetworks).flatten
Despite it's being a bit better readable, it performs about twice slower than the flat_map
version (due to the flatten
). So I've left the flat_map
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 it was the .values
instead of { |_, v|
that I most cared about
Checked commit tumido@524bc14 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Follow up on #54 "Fog google upgrade (to 1.3.3)" code cleanup
Fiine backport (to manageiq repo) details:
|
Let's follow up on #54 and incorporate some changes @agrare suggested.
Make the code neater and faster again!