Use exception instead of check if key is in dict

Since the amount of times that the key is in there is orders of magnitude
larger, it's better to catch the exception when it doesn't (as that is
slightly faster)
This commit is contained in:
Jaime van Kessel 2020-08-14 15:15:33 +02:00
parent 9c904f95ce
commit eee84a82bf
No known key found for this signature in database
GPG key ID: 3710727397403C91

View file

@ -393,7 +393,9 @@ class CuraContainerStack(ContainerStack):
if property_name == "settable_per_extruder": if property_name == "settable_per_extruder":
# Setable per extruder isn't a value that can ever change. So once we requested it once, we can just keep # Setable per extruder isn't a value that can ever change. So once we requested it once, we can just keep
# that in memory. # that in memory.
if key not in self._settable_per_extruder_cache: try:
return self._settable_per_extruder_cache[key]
except KeyError:
self._settable_per_extruder_cache[key] = super().getProperty(key, property_name, context) self._settable_per_extruder_cache[key] = super().getProperty(key, property_name, context)
return self._settable_per_extruder_cache[key] return self._settable_per_extruder_cache[key]