Skip to content

Commit

Permalink
Reduce allocations when applying operators
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkschumacher committed May 16, 2024
1 parent 18809e8 commit 279d001
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions solve_solver.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,14 +281,11 @@ func (s *solveImpl) Solve(
for iteration := 0; iteration < solveOptions.Iterations; iteration++ {
solveInformation.iteration = iteration
solveInformation.deltaScore = 0.0
solveInformation.solveOperators = make(
SolveOperators,
0,
len(s.solveOperators),
)

// we do not clear the elements of solveOperators as they are
// stable accross iterations. We do not risk a memory leak here.
solveInformation.solveOperators = solveInformation.solveOperators[:0]
s.solveEvents.Iterating.Trigger(solveInformation)
for _, solveOperator := range s.SolveOperators() {
for _, solveOperator := range s.solveOperators {
select {
case <-ctx.Done():
s.solveEvents.ContextDone.Trigger(solveInformation)
Expand Down

0 comments on commit 279d001

Please sign in to comment.