mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-13 03:44:02 -07: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:
parent
b79bf14607
commit
1ca4add91c
7 changed files with 15 additions and 15 deletions
|
@ -180,14 +180,14 @@ class BrookInventory:
|
|||
|
||||
# Group by project
|
||||
project_group = 'project_%s' % project.name
|
||||
if project_group in groups.keys():
|
||||
if project_group in groups:
|
||||
groups[project_group].append(instance.name)
|
||||
else:
|
||||
groups[project_group] = [instance.name]
|
||||
|
||||
# Group by status
|
||||
status_group = 'status_%s' % meta['hostvars'][instance.name]['brook_status']
|
||||
if status_group in groups.keys():
|
||||
if status_group in groups:
|
||||
groups[status_group].append(instance.name)
|
||||
else:
|
||||
groups[status_group] = [instance.name]
|
||||
|
@ -196,7 +196,7 @@ class BrookInventory:
|
|||
tags = meta['hostvars'][instance.name]['brook_tags']
|
||||
for tag in tags:
|
||||
tag_group = 'tag_%s' % tag
|
||||
if tag_group in groups.keys():
|
||||
if tag_group in groups:
|
||||
groups[tag_group].append(instance.name)
|
||||
else:
|
||||
groups[tag_group] = [instance.name]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue