From 94f0d8d78357f1b2bb890049c14276bf1174d79d Mon Sep 17 00:00:00 2001 From: kgriffs Date: Thu, 9 May 2013 17:00:52 -0400 Subject: [PATCH] perf: Decrease time to create a claim by ~1 us A simple change to the way kwargs was constructed made a signficant change in efficiency. Other places where the helpers.purge function are used will be optimized once Falcon releases support for storing results directly in a dict, unless they are None, making the purge function unnecessary. Implements: Blueprint bp/v1-obvious-optimizations Change-Id: I9abe4d497cedd7963ae0cccd85bc1096d20994a1 --- marconi/transport/wsgi/claims.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/marconi/transport/wsgi/claims.py b/marconi/transport/wsgi/claims.py index 30fc3ee2e..80e1c13b3 100644 --- a/marconi/transport/wsgi/claims.py +++ b/marconi/transport/wsgi/claims.py @@ -36,10 +36,8 @@ class CollectionResource(object): raise falcon.HTTPBadRequest(_('Bad request'), _('Missing claim metadata.')) - #TODO(zyuan): where do we define the limits? - kwargs = helpers.purge({ - 'limit': req.get_param_as_int('limit'), - }) + limit = req.get_param_as_int('limit') + claim_options = {} if limit is None else {'limit': limit} try: metadata = _filtered(helpers.read_json(req.stream)) @@ -47,7 +45,7 @@ class CollectionResource(object): queue_name, metadata=metadata, project=project_id, - **kwargs) + **claim_options) resp_msgs = list(msgs) if len(resp_msgs) != 0: