-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: BSON, Performance
-
Not Needed
Description
Update Long.fromBigInt to perform truncation identical to DataView.setBigInt64 and BigInt64Array. Currently any sized bigint can be passed into the long helper, it will be stringified and then passed to fromString, this could lead to many more iterations than necessary to construct a string.
AC (suggested)
- Truncate bigint input: BigInt.asIntN(64, value)
- Instead of converting the number to a string, bit wise shift the upper and lower 32 bits into JS numbers
- call the long constructor with low and high bits