Skip to content
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

Reduce allocations when applying operators #48

Merged
merged 2 commits into from
May 17, 2024
Merged
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
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 across 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
Loading