Skip to content

Commit eea0acc

Browse files
authored
log: using maps.Clone (#29392)
1 parent 6b39e92 commit eea0acc

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

log/handler_glog.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"errors"
2222
"fmt"
2323
"log/slog"
24+
"maps"
2425
"regexp"
2526
"runtime"
2627
"strconv"
@@ -145,10 +146,7 @@ func (h *GlogHandler) Enabled(ctx context.Context, lvl slog.Level) bool {
145146

146147
func (h *GlogHandler) WithAttrs(attrs []slog.Attr) slog.Handler {
147148
h.lock.RLock()
148-
siteCache := make(map[uintptr]slog.Level)
149-
for k, v := range h.siteCache {
150-
siteCache[k] = v
151-
}
149+
siteCache := maps.Clone(h.siteCache)
152150
h.lock.RUnlock()
153151

154152
patterns := []pattern{}

0 commit comments

Comments
 (0)