summary refs log tree commit diff
path: root/synapse/http/server.py
diff options
context:
space:
mode:
authorRichard van der Hoff <1389908+richvdh@users.noreply.github.com>2020-02-19 10:38:20 +0000
committerGitHub <noreply@github.com>2020-02-19 10:38:20 +0000
commitabf1e5c52669bd41ad803d4645809b6efdfcd61d (patch)
tree7bbe7e70a39f63d4c4a3dfab947966c993cc7fba /synapse/http/server.py
parentIncrease DB/CPU perf of `_is_server_still_joined` check. (#6936) (diff)
downloadsynapse-abf1e5c52669bd41ad803d4645809b6efdfcd61d.tar.xz
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.
Diffstat (limited to 'synapse/http/server.py')
-rw-r--r--synapse/http/server.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/synapse/http/server.py b/synapse/http/server.py
index 04bc2385a2..042a605198 100644
--- a/synapse/http/server.py
+++ b/synapse/http/server.py
@@ -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()