Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Commit

Permalink
perf: remove unneeded Buffer.from() call during deserialize
Browse files Browse the repository at this point in the history
This Buffer.from() call make Node.js copy and reinitialize a Buffer
object, and it is a minor bottleneck of js-ipfs.
  • Loading branch information
mcollina authored and vmx committed Dec 11, 2018
1 parent d56ed9a commit 4632596
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function deserialize (buffer, callback) {
return new DAGLink(link.Name, link.Tsize, link.Hash)
})

const data = pbn.Data == null ? Buffer.alloc(0) : Buffer.from(pbn.Data)
const data = pbn.Data == null ? Buffer.alloc(0) : pbn.Data

setImmediate(() => callback(null, new DAGNode(data, links, buffer.length)))
}
Expand Down

0 comments on commit 4632596

Please sign in to comment.