Skip to content

Commit

Permalink
unix: allocate signalNameMap with enough space
Browse files Browse the repository at this point in the history
Avoid re-allocations while filling signalNameMap.

Change-Id: I3017e856c2724debccad43324cbe2e60b68d869c
Reviewed-on: https://go-review.googlesource.com/c/sys/+/225017
Run-TryBot: Tobias Klauser <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
  • Loading branch information
tklauser committed Mar 23, 2020
1 parent 328b4cd commit 85ca7c5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion unix/syscall_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func SignalName(s syscall.Signal) string {
// The signal name should start with "SIG".
func SignalNum(s string) syscall.Signal {
signalNameMapOnce.Do(func() {
signalNameMap = make(map[string]syscall.Signal)
signalNameMap = make(map[string]syscall.Signal, len(signalList))
for _, signal := range signalList {
signalNameMap[signal.name] = signal.num
}
Expand Down

0 comments on commit 85ca7c5

Please sign in to comment.