summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Schubert <ben.c.schubert@gmail.com>2019-03-21 16:45:57 +0000
committerBenjamin Schubert <ben.c.schubert@gmail.com>2019-03-21 18:18:33 +0000
commit78a3b5f284ed87d2d2ec2d4049cac70a811723f1 (patch)
tree3fc975998279b4330fbae2a260659739e0780e4b
parentaa326c937b0146269be78ff03a554d6c1d7826cb (diff)
downloadbuildstream-bschubert/fix-double-lookup.tar.gz
plugin.py: Don't make a double lookup in the plugin table to get onebschubert/fix-double-lookup
This removes a double lookup done in the Plugin.__TABLE, which should speedup every invocation of this method.
-rw-r--r--buildstream/plugin.py7
1 files 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()
#