This repository has been archived by the owner on Aug 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: make this._json calculation lazy
I've been doing some profiling of js-ipfs and where there are large amounts of DAG operations being performed (importing all of npm to ipfs, for example) we spend about 1.8-2.5% of our time in the creation of this._json objects, even though they are not always used, so this PR makes them be created when first requested. It also passes the `this._json` object through `Object.freeze` becase otherwise we expose a mutable object to the world - it seems odd that we've taken pains to ensure that the properties of a DAGNode/DAGLink are immutable, then expose objects whose properties are not immutable. Finally it makes more use of the `cids` module to parse CIDs from multihashes as the `cids` module respects CIDv1 versions/codecs if present whereas the `multihashes` module does not and is only really suitable for use with CIDv0.
- Loading branch information
1 parent
97bbf30
commit d138c95
Showing
6 changed files
with
34 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters