element.py: Don't calculate strong key if not required
diff --git a/buildstream/_cachekeycontroller/nonstrictcachekeycontroller.py b/buildstream/_cachekeycontroller/nonstrictcachekeycontroller.py
index 12518a2..b47d088 100644
--- a/buildstream/_cachekeycontroller/nonstrictcachekeycontroller.py
+++ b/buildstream/_cachekeycontroller/nonstrictcachekeycontroller.py
@@ -46,11 +46,7 @@
                 # Load the strong cache key from the artifact
                 self._strong_key = element._get_strong_key_from_artifact()
 
-            # XXX: This is a significant change from how strong cache keys were originally
-            #      calculated. It seems to be correct, but I am not certain it's the best way.
-            #      If bugs occur, try replacing the conditional with
-            #      `element._Element__assemble_scheduled or element._Element__assemble_done`.
-            elif element._is_required():
+            else:
                 # Artifact will or has been built, not downloaded
                 dependencies = [
                     e._get_cache_key() for e in element.dependencies(Scope.BUILD)
diff --git a/buildstream/element.py b/buildstream/element.py
index b45d997..c790e77 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -2986,8 +2986,10 @@
         if not self.__strict_artifact:
             return
 
-        # The final cache key can be None here only in non-strict mode
-        if not self.__cache_key_ctrl.get_key(_KeyStrength.STRONG):
+        # The final cache key can be None here only in non-strict mode.
+        # If it's not required, don't calculate it since it's expensve to try
+        # to pull it first.
+        if not self.__cache_key_ctrl.get_key(_KeyStrength.STRONG) and self._is_required():
             strong_cache_key = self.__cache_key_ctrl.calculate_strong_key(self)
 
             if strong_cache_key is None: