Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Tiny optimisation for _get_handler_for_request #6950

Merged
merged 1 commit into from
Feb 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/6950.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Tiny optimisation for incoming HTTP request dispatch.
4 changes: 3 additions & 1 deletion synapse/http/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,12 @@ def _get_handler_for_request(self, request):
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()
Expand Down