> On 16 Dec 2020, at 5:49 am, jake...@gmail.com <jake6...@gmail.com> wrote: > > I have no special knowledge of the code, but it looks like the reason is so > that ServeMux.es <http://servemux.es/>, which is a []muxEntry, can be > searched. See the latter half of `func (mux *ServeMux) match() > <https://golang.org/src/net/http/server.go?h=ServeMux#L2279>` for example. > > That said, it may be possible to have ServeMux.m be a `map[string]Handler` > instead. If so, then my guess is that ServeMux.m and ServeMux.es > <http://servemux.es/> both use muxEntry just to slightly simplify the code. > The assumption would be that the memory cost is negligible. But I could be > wrong, and maybe there is a case where ServeMux.m must be a muxEntry, and > not just a Handler.
Thank you for sharing your insights. Yes, I was looking at the append..() code slightly below and I saw a usage of that there. > > On Monday, December 14, 2020 at 8:52:27 PM UTC-5 amits...@gmail.com > <http://gmail.com/> wrote: > Hi all, the ServerMux struct is currently defined as: > > type ServeMux struct { > // other fields > m map[string]muxEntry > } > > > The muxEntry is then defined as: > > type muxEntry struct { > h Handler > pattern string > } > > Is there any reason for also storing the pattern in the muxEntry since it > *seems* like the lookup only happens using the key in the map of ServeMux? > > Thanks for any insights. > > > Best Regards, > Amit > > > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com > <mailto:golang-nuts+unsubscr...@googlegroups.com>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/42544681-9f1f-4e76-a4da-52330ee1628en%40googlegroups.com > > <https://groups.google.com/d/msgid/golang-nuts/42544681-9f1f-4e76-a4da-52330ee1628en%40googlegroups.com?utm_medium=email&utm_source=footer>. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/8127E7CE-6A64-4B5A-A7C6-CB144A0C14BD%40gmail.com.