]> Cypherpunks repositories - gostls13.git/commit
net/http: mapping data structure
authorJonathan Amsterdam <jba@google.com>
Mon, 11 Sep 2023 14:59:48 +0000 (10:59 -0400)
committerJonathan Amsterdam <jba@google.com>
Tue, 12 Sep 2023 17:47:07 +0000 (17:47 +0000)
commit9f5a2cf61cc0c2389c577a00b5914235236d6c7f
tree95843e65d0c8df1596a48e162bb9ae9b59d80684
parent3602465954016ea1daef407764a7e4f23ab1c198
net/http: mapping data structure

Our goal for the new ServeMux patterns is to match the routing
performance of the existing ServeMux patterns. To achieve that
we needed to optimize lookup for small maps.

This CL introduces a simple data structure called a mapping that
optimizes lookup by using a slice for small collections of key-value
pairs, switching to a map when the collection gets large.

Mappings are a core part of the routing algorithm, which uses a
decision tree to match path elements.   The children of a tree node are
held in a mapping.

Change-Id: I923b3ad1376ace2c3e3421aa9b802ad12d47c871
Reviewed-on: https://go-review.googlesource.com/c/go/+/526617
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Eli Bendersky <eliben@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
src/net/http/mapping.go [new file with mode: 0644]
src/net/http/mapping_test.go [new file with mode: 0644]