summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenjamin Schubert <bschubert15@bloomberg.net>2019-12-09 15:02:47 +0000
committerBenjamin Schubert <bschubert15@bloomberg.net>2019-12-09 15:53:12 +0000
commit143b720f3819e366c712654473b6276c06f3b7ee (patch)
tree7f023fc599011c7ad9360e6ecfcdf8719e0824ca /src
parent2503f0be0cfe01d5391461f8a11a9c44a10e6af9 (diff)
downloadbuildstream-bschubert/optimize-consistency-new.tar.gz
element.py: Optimize _should_fetch conditionbschubert/optimize-consistency-new
By looking at the flag first, we can avoid expensive checks on whether the element is cached or not.
Diffstat (limited to 'src')
-rw-r--r--src/buildstream/element.py9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/buildstream/element.py b/src/buildstream/element.py
index d5ae224c4..14ee63612 100644
--- a/src/buildstream/element.py
+++ b/src/buildstream/element.py
@@ -2215,12 +2215,9 @@ class Element(Plugin):
Args:
fetch_original (bool): whether we need to original unstaged source
"""
- if (self._has_all_sources_cached() and fetch_original) or (
- self._has_all_sources_in_source_cache() and not fetch_original
- ):
- return False
- else:
- return True
+ if fetch_original:
+ return not self._has_all_sources_cached()
+ return not self._has_all_sources_in_source_cache()
# _set_can_query_cache_callback()
#