From ca133feb43885ed747c9cc7289fd602e868c5895 Mon Sep 17 00:00:00 2001 From: Benjamin Schubert Date: Mon, 9 Dec 2019 15:02:47 +0000 Subject: 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. --- src/buildstream/element.py | 9 +++------ 1 file 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() # -- cgit v1.2.1