Commit cae9d4b
fix: remove use of Object.defineProperties in CID class
`Object.defineProperties` is a performance bottleneck in applications that
create lots and lots of CIDs (e.g. IPFS) so this PR removes it.
The `asCID` property is changed to be a [private class field](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Private_class_fields)
which requires increasing the minimum supported EcmaScript version but I don't
know if that's a big deal or not. It does seem to make the property non-enumerable
though.
The CID class now implements a `Link` interface that has public `byteOffset`
and `byteLength` properties so these become regular properties
`code`, `version`, `multihash` and `bytes` become writable/configurable
but they are marked with `@readonly` so maybe that's enough?
Fixes #2001 parent 60b292d commit cae9d4b
2 files changed
+9
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
160 | | - | |
| 160 | + | |
| 161 | + | |
161 | 162 | | |
162 | 163 | | |
163 | 164 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
64 | 67 | | |
65 | 68 | | |
66 | 69 | | |
| |||
86 | 89 | | |
87 | 90 | | |
88 | 91 | | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
| 92 | + | |
| 93 | + | |
100 | 94 | | |
101 | | - | |
102 | | - | |
| 95 | + | |
| 96 | + | |
103 | 97 | | |
104 | 98 | | |
105 | 99 | | |
| |||
568 | 562 | | |
569 | 563 | | |
570 | 564 | | |
571 | | - | |
572 | | - | |
0 commit comments