mirror of
https://github.com/golang/go
synced 2024-09-28 19:24:29 -06:00
internal/bisect: replace atomicPointerDedup to simplify the code
"atomicPointerDedup" is a redundancy of "atomic.Pointer".
Since Go 1.22 now requires the final point release of Go 1.20 or
later for bootstrap, Go 1.19's atomic.Pointer can be used
without problems.
atomicPointerDedup is unnecessary and we can remove it now.
Change-Id: I0a65ad0b6649cecb73d58dc39c5fd736390d5fa5
GitHub-Last-Rev: 6c6e9421fb
GitHub-Pull-Request: golang/go#65987
Reviewed-on: https://go-review.googlesource.com/c/go/+/567656
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
c764d56ff1
commit
49204af37e
@ -180,7 +180,6 @@ import (
|
||||
"runtime"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// New creates and returns a new Matcher implementing the given pattern.
|
||||
@ -311,22 +310,7 @@ type Matcher struct {
|
||||
quiet bool // disables all reporting. reset if verbose is true. use case is -d=fmahash=qn
|
||||
enable bool // when true, list is for “enable and report” (when false, “disable and report”)
|
||||
list []cond // conditions; later ones win over earlier ones
|
||||
dedup atomicPointerDedup
|
||||
}
|
||||
|
||||
// atomicPointerDedup is an atomic.Pointer[dedup],
|
||||
// but we are avoiding using Go 1.19's atomic.Pointer
|
||||
// until the bootstrap toolchain can be relied upon to have it.
|
||||
type atomicPointerDedup struct {
|
||||
p unsafe.Pointer
|
||||
}
|
||||
|
||||
func (p *atomicPointerDedup) Load() *dedup {
|
||||
return (*dedup)(atomic.LoadPointer(&p.p))
|
||||
}
|
||||
|
||||
func (p *atomicPointerDedup) CompareAndSwap(old, new *dedup) bool {
|
||||
return atomic.CompareAndSwapPointer(&p.p, unsafe.Pointer(old), unsafe.Pointer(new))
|
||||
dedup atomic.Pointer[dedup]
|
||||
}
|
||||
|
||||
// A cond is a single condition in the matcher.
|
||||
|
Loading…
Reference in New Issue
Block a user