Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 12, 14:30 UTC
caddyconfig: Use empty struct instead of bool in map (close #6224) (#6227)
danish-mehmood committed
Apr 8, 2024 at 16:12 UTC
f4840cfeb85ac33d29a1ab88d474750041a98733
2 files changed
+5
-5
caddyconfig/caddyfile/importgraph.go
+4
-4
@@ -21,18 +21,18 @@ import (
21
type adjacency map[string][]string
22
23
type importGraph struct {
24
- nodes map[string]bool
24
+ nodes map[string]struct{}
25
edges adjacency
26
}
27
28
func (i *importGraph) addNode(name string) {
29
if i.nodes == nil {
30
- i.nodes = make(map[string]bool)
30
+ i.nodes = make(map[string]struct{})
31
}
32
if _, exists := i.nodes[name]; exists {
33
return
34
}
35
- i.nodes[name] = true
35
+ i.nodes[name] = struct{}{}
36
}
37
38
func (i *importGraph) addNodes(names []string) {
@@ -66,7 +66,7 @@ func (i *importGraph) addEdge(from, to string) error {
66
}
67
68
if i.nodes == nil {
69
- i.nodes = make(map[string]bool)
69
+ i.nodes = make(map[string]struct{})
70
}
71
if i.edges == nil {
72
i.edges = make(adjacency)
caddyconfig/caddyfile/parse.go
+1
-1
@@ -50,7 +50,7 @@ func Parse(filename string, input []byte) ([]ServerBlock, error) {
50
p := parser{
51
Dispenser: NewDispenser(tokens),
52
importGraph: importGraph{
53
- nodes: make(map[string]bool),
53
+ nodes: make(map[string]struct{}),
54
edges: make(adjacency),
55
},
56
}