Skip to content

internal/bisect: replace atomicPointerDedup to simplify the code #65987

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 1 addition & 17 deletions src/internal/bisect/bisect.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ import (
"runtime"
"sync"
"sync/atomic"
"unsafe"
)

// New creates and returns a new Matcher implementing the given pattern.
Expand Down Expand Up @@ -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.
Expand Down