]> Cypherpunks repositories - gostls13.git/commit
net/http: speed up ServeMux matching
authorCarl Mastrangelo <notcarl@google.com>
Fri, 26 Oct 2018 05:03:43 +0000 (22:03 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Fri, 2 Nov 2018 23:22:57 +0000 (23:22 +0000)
commit1645dfa23fbb1d1bab258d1c458f08d9f2741295
treed374d0bcdf55a0e64bc89c393b83d21956bbe68c
parent3813edf26edb78620632dc9c7d66096e5b2b5019
net/http: speed up ServeMux matching

Scanning through all path patterns is not necessary, since the
paths do not change frequently.  Instead, maintain a sorted list
of path prefixes and return the first match.

name            old time/op  new time/op  delta
ServerMatch-12   134ns ± 3%    17ns ± 4%  -86.95%  (p=0.000 n=19+20)

Change-Id: I15b4483dc30db413321435ee6815fc9bf2bcc546
Reviewed-on: https://go-review.googlesource.com/c/144937
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/net/http/server.go
src/net/http/server_test.go [new file with mode: 0644]