mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-09-06 19:31:55 +00:00
Tiny optimisation for _get_handler_for_request (#6950)
we have hundreds of path_regexes (see #5118), so let's not convert the same bytes to str for each of them.
This commit is contained in:
parent
0d0bc35792
commit
abf1e5c526
1
changelog.d/6950.misc
Normal file
1
changelog.d/6950.misc
Normal file
@ -0,0 +1 @@
|
||||
Tiny optimisation for incoming HTTP request dispatch.
|
@ -353,10 +353,12 @@ class JsonResource(HttpServer, resource.Resource):
|
||||
if request.method == b"OPTIONS":
|
||||
return _options_handler, "options_request_handler", {}
|
||||
|
||||
request_path = request.path.decode("ascii")
|
||||
|
||||
# Loop through all the registered callbacks to check if the method
|
||||
# and path regex match
|
||||
for path_entry in self.path_regexs.get(request.method, []):
|
||||
m = path_entry.pattern.match(request.path.decode("ascii"))
|
||||
m = path_entry.pattern.match(request_path)
|
||||
if m:
|
||||
# We found a match!
|
||||
return path_entry.callback, path_entry.servlet_classname, m.groupdict()
|
||||
|
Loading…
Reference in New Issue
Block a user