summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTristan van Berkom <tristan@codethink.co.uk>2020-10-27 17:08:39 +0900
committerTristan Van Berkom <tristan.van.berkom@gmail.com>2020-10-27 11:28:02 +0000
commitceeca58f96bea79d8163433adec1591de33cfa98 (patch)
tree99dc858ec0e1970ee8f7c6c623c1216da5c9e242 /src
parenta39b57ada4302d2835ccc2bd8e23d191402da275 (diff)
downloadbuildstream-ceeca58f96bea79d8163433adec1591de33cfa98.tar.gz
_loader/loader.py: Avoid double dictionary lookup
Use try / except KeyError instead.
Diffstat (limited to 'src')
-rw-r--r--src/buildstream/_loader/loader.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/buildstream/_loader/loader.py b/src/buildstream/_loader/loader.py
index c260eefe5..90b7fbe50 100644
--- a/src/buildstream/_loader/loader.py
+++ b/src/buildstream/_loader/loader.py
@@ -854,9 +854,9 @@ class Loader:
# If the element is already loaded in the target loader, then there
# is no need for a shallow load.
- if element_name in target_loader._elements:
+ try:
element = target_loader._elements[element_name]
- else:
+ except KeyError:
# Shallow load the the element.
element = target_loader._load_file_no_deps(element_name, provenance_node)