[7/7] framework/status.py: Add early return to status_lookup

Submitted by Dylan Baker on Sept. 2, 2015, 9:18 p.m.

Details

Message ID 1441228706-8398-8-git-send-email-baker.dylan.c@gmail.com
State New, archived
Headers show

Not browsing as part of any series.

Commit Message

Dylan Baker Sept. 2, 2015, 9:18 p.m.
It's rediculously expensive to send a Status through the status_lookup
factory, it's much cheaper to return early, and doesn't really affect
non Status lookups.

Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
---
 framework/status.py | 5 +++++
 1 file changed, 5 insertions(+)

Patch hide | download patch | download mbox

diff --git a/framework/status.py b/framework/status.py
index 51a7e21..28f8bfa 100644
--- a/framework/status.py
+++ b/framework/status.py
@@ -80,6 +80,11 @@  def status_lookup(status):
     does not correspond to a key it will raise an exception
 
     """
+    # Don't go through this if what we've been passed already is a status, it's
+    # very expensive
+    if isinstance(status, Status):
+        return status
+
     status_dict = {
         'skip': SKIP,
         'pass': PASS,