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:
parent
8b31b2e9b0
commit
94f0d8d783
@ -36,10 +36,8 @@ class CollectionResource(object):
|
|||||||
raise falcon.HTTPBadRequest(_('Bad request'),
|
raise falcon.HTTPBadRequest(_('Bad request'),
|
||||||
_('Missing claim metadata.'))
|
_('Missing claim metadata.'))
|
||||||
|
|
||||||
#TODO(zyuan): where do we define the limits?
|
limit = req.get_param_as_int('limit')
|
||||||
kwargs = helpers.purge({
|
claim_options = {} if limit is None else {'limit': limit}
|
||||||
'limit': req.get_param_as_int('limit'),
|
|
||||||
})
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
metadata = _filtered(helpers.read_json(req.stream))
|
metadata = _filtered(helpers.read_json(req.stream))
|
||||||
@ -47,7 +45,7 @@ class CollectionResource(object):
|
|||||||
queue_name,
|
queue_name,
|
||||||
metadata=metadata,
|
metadata=metadata,
|
||||||
project=project_id,
|
project=project_id,
|
||||||
**kwargs)
|
**claim_options)
|
||||||
resp_msgs = list(msgs)
|
resp_msgs = list(msgs)
|
||||||
|
|
||||||
if len(resp_msgs) != 0:
|
if len(resp_msgs) != 0:
|
||||||
|
Loading…
Reference in New Issue
Block a user