Merge "Optimize the code performance"

This commit is contained in:
Jenkins 2015-11-05 22:39:41 +00:00 committed by Gerrit Code Review
commit 22e294c418

View File

@ -79,12 +79,7 @@ class NameCheckMiddleware(object):
self.logger.debug("name_check: self.forbidden_chars %s" %
self.forbidden_chars)
for c in unquote(req.path):
if c in self.forbidden_chars:
return True
else:
pass
return False
return any((c in unquote(req.path)) for c in self.forbidden_chars)
def check_length(self, req):
'''
@ -93,10 +88,7 @@ class NameCheckMiddleware(object):
Returns False if the length is <= the maximum
'''
length = len(unquote(req.path))
if length > self.maximum_length:
return True
else:
return False
return length > self.maximum_length
def check_regexp(self, req):
'''