Skip to content

Commit

Permalink
perf: pre-allocate in toCommit
Browse files Browse the repository at this point in the history
  • Loading branch information
ivokub committed Nov 22, 2024
1 parent a90acb3 commit 2c943f1
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions std/math/emulated/field_mul.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@ type mulCheck[T FieldParams] struct {
}

func (mc *mulCheck[T]) toCommit() []frontend.Variable {
var toCommit []frontend.Variable
nbToCommit := len(mc.a.Limbs) + len(mc.b.Limbs) + len(mc.r.Limbs) + len(mc.k.Limbs) + len(mc.c.Limbs)
if mc.p != nil {
nbToCommit += len(mc.p.Limbs)
}
toCommit := make([]frontend.Variable, 0, nbToCommit)
toCommit = append(toCommit, mc.a.Limbs...)
toCommit = append(toCommit, mc.b.Limbs...)
toCommit = append(toCommit, mc.r.Limbs...)
Expand Down Expand Up @@ -747,7 +751,11 @@ type mvCheck[T FieldParams] struct {
}

func (mc *mvCheck[T]) toCommit() []frontend.Variable {
var toCommit []frontend.Variable
nbToCommit := len(mc.r.Limbs) + len(mc.k.Limbs) + len(mc.c.Limbs)
for j := range mc.vals {
nbToCommit += len(mc.vals[j].Limbs)
}
toCommit := make([]frontend.Variable, 0, nbToCommit)
toCommit = append(toCommit, mc.r.Limbs...)
toCommit = append(toCommit, mc.k.Limbs...)
toCommit = append(toCommit, mc.c.Limbs...)
Expand Down

0 comments on commit 2c943f1

Please sign in to comment.