mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
Performance improvement using in-operator on dicts
Just a small cleanup for the existing occurrences. Using the in-operator for hash lookups is faster than using .keys() http://stackoverflow.com/questions/29314269/why-do-key-in-dict-and-key-in-dict-keys-have-the-same-output
This commit is contained in:
@@ -2724,7 +2724,7 @@ class GenericBsdIfconfigNetwork(Network):
|
||||
return []
|
||||
|
||||
def merge_default_interface(self, defaults, interfaces, ip_type):
|
||||
if not 'interface' in defaults.keys():
|
||||
if 'interface' not in defaults:
|
||||
return
|
||||
if not defaults['interface'] in interfaces:
|
||||
return
|
||||
@@ -3045,7 +3045,7 @@ class SunOSNetwork(GenericBsdIfconfigNetwork):
|
||||
|
||||
def parse_interface_line(self, words, current_if, interfaces):
|
||||
device = words[0][0:-1]
|
||||
if device not in interfaces.keys():
|
||||
if device not in interfaces:
|
||||
current_if = {'device': device, 'ipv4': [], 'ipv6': [], 'type': 'unknown'}
|
||||
else:
|
||||
current_if = interfaces[device]
|
||||
|
||||
Reference in New Issue
Block a user