Skip to content

Commit

Permalink
Add ArrayIterator.CanMutate() predicate function
Browse files Browse the repository at this point in the history
  • Loading branch information
fxamacker committed Oct 3, 2023
1 parent c07907d commit f671189
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion array.go
Original file line number Diff line number Diff line change
Expand Up @@ -3359,6 +3359,10 @@ type ArrayIterator struct {
readOnly bool
}

func (i *ArrayIterator) CanMutate() bool {
return !i.readOnly
}

func (i *ArrayIterator) Next() (Value, error) {
if i.remainingCount == 0 {
return nil, nil
Expand Down Expand Up @@ -3391,7 +3395,7 @@ func (i *ArrayIterator) Next() (Value, error) {
return nil, wrapErrorfAsExternalErrorIfNeeded(err, "failed to get storable's stored value")
}

if !i.readOnly {
if i.CanMutate() {
// Set up notification callback in child value so
// when child value is modified parent a is notified.
i.array.setCallbackWithChild(uint64(i.indexInArray), element, maxInlineArrayElementSize)
Expand Down

0 comments on commit f671189

Please sign in to comment.