diff options
author | Benjamin Schubert <bschubert15@bloomberg.net> | 2019-12-09 15:02:47 +0000 |
---|---|---|
committer | Benjamin Schubert <bschubert15@bloomberg.net> | 2020-01-16 16:33:19 +0000 |
commit | ca133feb43885ed747c9cc7289fd602e868c5895 (patch) | |
tree | 34aa9ba4aa31dd595feaa354055c372bc53d0c52 | |
parent | 6021d8544e8808419d1b44f0cf850ce3ca3290f5 (diff) | |
download | buildstream-ca133feb43885ed747c9cc7289fd602e868c5895.tar.gz |
element.py: Optimize _should_fetch condition
By looking at the flag first, we can avoid expensive checks on whether
the element is cached or not.
-rw-r--r-- | src/buildstream/element.py | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/buildstream/element.py b/src/buildstream/element.py index ee2db71c6..a12527c3c 100644 --- a/src/buildstream/element.py +++ b/src/buildstream/element.py @@ -2208,12 +2208,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() # |