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
This commit is contained in:
kgriffs 2013-05-09 17:00:52 -04:00
parent 8b31b2e9b0
commit 94f0d8d783

View File

@ -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: