Skip to content

Commit

Permalink
avoid atomic level overhead for amd64
Browse files Browse the repository at this point in the history
  • Loading branch information
phuslu committed Apr 22, 2024
1 parent a803cd8 commit b1237e2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
4 changes: 0 additions & 4 deletions logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,6 @@ var timeOffset, timeZone = func() (int64, string) {
return int64(n), s
}()

func (l *Logger) silent(level Level) bool {
return uint32(level) < atomic.LoadUint32((*uint32)(&l.Level))
}

func (l *Logger) header(level Level) *Entry {
e := epool.Get().(*Entry)
e.buf = e.buf[:0]
Expand Down
8 changes: 8 additions & 0 deletions logger_arch_amd64.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//go:build amd64
// +build amd64

package log

func (l *Logger) silent(level Level) bool {
return level < l.Level
}
12 changes: 12 additions & 0 deletions logger_arch_others.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//go:build !amd64
// +build !amd64

package log

import (
"sync/atomic"
)

func (l *Logger) silent(level Level) bool {
return uint32(level) < atomic.LoadUint32((*uint32)(&l.Level))
}

0 comments on commit b1237e2

Please sign in to comment.