From 78a3b5f284ed87d2d2ec2d4049cac70a811723f1 Mon Sep 17 00:00:00 2001 From: Benjamin Schubert Date: Thu, 21 Mar 2019 16:45:57 +0000 Subject: plugin.py: Don't make a double lookup in the plugin table to get one This removes a double lookup done in the Plugin.__TABLE, which should speedup every invocation of this method. --- buildstream/plugin.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/buildstream/plugin.py b/buildstream/plugin.py index c139c8cb7..f9c1dd838 100644 --- a/buildstream/plugin.py +++ b/buildstream/plugin.py @@ -714,8 +714,11 @@ class Plugin(): # @classmethod def _lookup(cls, unique_id): - assert unique_id in cls.__TABLE, "Could not find plugin with ID {}".format(unique_id) - return cls.__TABLE[unique_id] + try: + return cls.__TABLE[unique_id] + except KeyError: + assert False, "Could not find plugin with ID {}".format(unique_id) + raise # In case a user is running with "python -O" # _get_context() # -- cgit v1.2.1