Skip to content

Commit

Permalink
remove Object.NumProtos
Browse files Browse the repository at this point in the history
The method wasn't used anywhere, and it isn't enough faster than ForeachProto to justify writing tests for it specifically.
  • Loading branch information
zephyrtronium committed May 20, 2020
1 parent 6c35c2f commit 6815c88
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions internal/slots.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,29 +105,10 @@ func (o *Object) Protos() []*Object {
return r
}

// NumProtos returns the number of protos the object has. This is more
// efficient than using ForeachProto to count the protos.
func (o *Object) NumProtos() int {
r := 0
p := o.protoHead()
if p == nil {
return 0
}
r++
for _, n := o.protos.nextR(); n != nil; _, n = n.nextR() {
r++
}
return r
}

// ForeachProto calls exec on each of the object's protos. exec must not modify
// o's protos list. If exec returns false, then the iteration ceases.
func (o *Object) ForeachProto(exec func(p *Object) bool) {
p := (*Object)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(&o.protos.p))))
for p == logicalDeleted {
p = (*Object)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(&o.protos.p))))
}
if p == nil || !exec(p) {
if p := o.protoHead(); p == nil || !exec(p) {
return
}
for p, n := o.protos.nextR(); n != nil; p, n = n.nextR() {
Expand Down

0 comments on commit 6815c88

Please sign in to comment.