Skip to content

Commit

Permalink
encoding: eliminate unnecessary allocations (algorand#5655)
Browse files Browse the repository at this point in the history
  • Loading branch information
algorandskiy authored Aug 29, 2023
1 parent 348944b commit 12ae503
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions merklesignature/persistentMerkleSignatureScheme.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ func (s *Secrets) Persist(store db.Accessor) error {
return fmt.Errorf("Secrets.Persist: %w", ErrKeyLifetimeIsZero)
}
round := indexToRound(s.FirstValid, s.KeyLifetime, 0)
encodedKey := protocol.GetEncodingBuf()
encodedBuf := protocol.GetEncodingBuf()
encodedKey := encodedBuf.Bytes()
err := store.Atomic(func(ctx context.Context, tx *sql.Tx) error {
err := InstallStateProofTable(tx) // assumes schema table already exists (created by partInstallDatabase)
if err != nil {
Expand Down Expand Up @@ -126,7 +127,7 @@ func (s *Secrets) Persist(store db.Accessor) error {

return nil
})
protocol.PutEncodingBuf(encodedKey)
protocol.PutEncodingBuf(encodedBuf.Update(encodedKey))
if err != nil {
return fmt.Errorf("Secrets.Persist: %w", err)
}
Expand Down

0 comments on commit 12ae503

Please sign in to comment.