Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-4954

Update Long.fromBigInt to perform truncation on bigint inputs

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: BSON, Performance
    • Labels:
    • 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

            Assignee:
            Unassigned Unassigned
            Reporter:
            neal.beeken@mongodb.com Neal Beeken
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: