Performance improvement using in-operator on dicts

Just a small cleanup for the existing occurances.

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:
Dag Wieers 2016-11-17 15:08:12 +01:00 committed by Brian Coca
parent 6a6113e951
commit ffb80926ce

View file

@ -2782,11 +2782,11 @@ class GenericBsdIfconfigNetwork(Network):
return
ifinfo = interfaces[defaults['interface']]
# copy all the interface values across except addresses
for item in ifinfo.keys():
for item in ifinfo:
if item != 'ipv4' and item != 'ipv6':
defaults[item] = ifinfo[item]
if len(ifinfo[ip_type]) > 0:
for item in ifinfo[ip_type][0].keys():
for item in ifinfo[ip_type][0]:
defaults[item] = ifinfo[ip_type][0][item]