Skip to content

Commit

Permalink
Add TODOs
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed Nov 22, 2021
1 parent ba58bd5 commit 0ae2bf1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/trie/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ func encodeNode(n node, buffer *bytes.Buffer, parallel bool) (err error) {
n.encodingMu.Lock()
defer n.encodingMu.Unlock()

// TODO remove this copying since it defeats the purpose of `buffer`
// and the sync.Pool.
n.encoding = make([]byte, buffer.Len())
copy(n.encoding, buffer.Bytes())
return nil
Expand Down
2 changes: 2 additions & 0 deletions lib/trie/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@ func (l *leaf) encodeAndHash() (encoding, hash []byte, err error) {
bufferBytes := buffer.Bytes()

l.encodingMu.Lock()
// TODO remove this copying since it defeats the purpose of `buffer`
// and the sync.Pool.
l.encoding = make([]byte, len(bufferBytes))
copy(l.encoding, bufferBytes)
l.encodingMu.Unlock()
Expand Down

0 comments on commit 0ae2bf1

Please sign in to comment.