diff options
| author | Brad Fitzpatrick <bradfitz@golang.org> | 2016-03-16 20:14:13 +0000 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2016-03-16 21:11:21 +0000 |
| commit | 8540a1c4dfd6f4950f5a1da6241c76765262ddbd (patch) | |
| tree | 8defc285fcf98c7f19058d23415f92b364571b46 /src/net/http/server.go | |
| parent | 826831acf7426f4e5e27198f96dbb07f933551b8 (diff) | |
| download | go-8540a1c4dfd6f4950f5a1da6241c76765262ddbd.tar.xz | |
net/http: remove init func reference to ServeMux
Shrinks cmd/go by 30KB.
Change-Id: Ied31192e85af76ebac743f8cc12bd9ef6ec5048f
Reviewed-on: https://go-review.googlesource.com/20765
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/net/http/server.go')
| -rw-r--r-- | src/net/http/server.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/net/http/server.go b/src/net/http/server.go index 3834630a59..17c2890aa7 100644 --- a/src/net/http/server.go +++ b/src/net/http/server.go @@ -1800,10 +1800,12 @@ type muxEntry struct { } // NewServeMux allocates and returns a new ServeMux. -func NewServeMux() *ServeMux { return &ServeMux{m: make(map[string]muxEntry)} } +func NewServeMux() *ServeMux { return new(ServeMux) } // DefaultServeMux is the default ServeMux used by Serve. -var DefaultServeMux = NewServeMux() +var DefaultServeMux = &defaultServeMux + +var defaultServeMux ServeMux // Does path match pattern? func pathMatch(pattern, path string) bool { @@ -1926,6 +1928,9 @@ func (mux *ServeMux) Handle(pattern string, handler Handler) { panic("http: multiple registrations for " + pattern) } + if mux.m == nil { + mux.m = make(map[string]muxEntry) + } mux.m[pattern] = muxEntry{explicit: true, h: handler, pattern: pattern} if pattern[0] != '/' { |
