Skip to content

Commit

Permalink
removeConstantEvaluable holds a lock for its entire implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
cdzombak committed Oct 23, 2024
1 parent 7420284 commit 45c0ecc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,9 @@ func (a *aggregator) Remove(ctx context.Context, eval Evaluable) error {
}

func (a *aggregator) removeConstantEvaluable(_ context.Context, eval Evaluable) error {
a.lock.Lock()
defer a.lock.Unlock()

// Find the index of the evaluable in constants and yank out.
idx := -1
for n, item := range a.constants {
Expand All @@ -483,9 +486,7 @@ func (a *aggregator) removeConstantEvaluable(_ context.Context, eval Evaluable)
return ErrEvaluableNotFound
}

a.lock.Lock()
a.constants = append(a.constants[:idx], a.constants[idx+1:]...)
a.lock.Unlock()
return nil
}

Expand Down

0 comments on commit 45c0ecc

Please sign in to comment.