Convert dict to set

This commit is contained in:
John Piasetzki 2016-10-20 00:16:16 -04:00
parent d1beabfc8f
commit f4b45deb7f

View File

@ -50,9 +50,8 @@ class Router:
""" """
# Dict for faster lookups of if method allowed # Dict for faster lookups of if method allowed
methods_dict = None
if methods: if methods:
methods_dict = {method: True for method in methods} methods = frozenset(methods)
parameters = [] parameters = []
@ -73,7 +72,7 @@ class Router:
pattern = re.compile(r'^{}$'.format(pattern_string)) pattern = re.compile(r'^{}$'.format(pattern_string))
route = Route( route = Route(
handler=handler, methods=methods_dict, pattern=pattern, handler=handler, methods=methods, pattern=pattern,
parameters=parameters) parameters=parameters)
self.routes.append(route) self.routes.append(route)