Skip to content

Commit 27f6bea

Browse files
kolyshkinLuap99
authored andcommitted
activation: simplify ListenersWithNames
As map lookup returns nil if no key is found, and append will create a new slice if it's first argument is nil, we can greatly simplify the loop, as suggested in [1]. [1]: #448 (comment) Reported-by: Paul Holzinger <[email protected]> Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent e615438 commit 27f6bea

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

activation/listeners.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,7 @@ func ListenersWithNames() (map[string][]net.Listener, error) {
4545

4646
for _, f := range files {
4747
if pc, err := net.FileListener(f); err == nil {
48-
current, ok := listeners[f.Name()]
49-
if !ok {
50-
listeners[f.Name()] = []net.Listener{pc}
51-
} else {
52-
listeners[f.Name()] = append(current, pc)
53-
}
48+
listeners[f.Name()] = append(listeners[f.Name()], pc)
5449
f.Close()
5550
}
5651
}

0 commit comments

Comments
 (0)