Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-1067

ObjectId could have a slightly smaller internal representation

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 2.1
    • None
    • BSON
    • None

    Description

      An ObjectId is 12 bytes long, but our current implementation:

      private int _timestamp;
      private int _machine;
      private short _pid;
      private int _increment;

      means that 14 bytes are used. (two fields, _machine and _increment, are 1 byte larger than they need to be).

      We could instead represent the 12 bytes internally as:

      private int _a;
      private int _b;
      private int _c;

      Which is exactly 12 bytes.

      We could easily reimplement the Timestamp, MachineId, Pid and Increment properties to extract the necessary bytes from _a, _b and _c and synthesize the corresponding return value, so this would not be a backward breaking change.

      Attachments

        Activity

          People

            robert@mongodb.com Robert Stam
            robert@mongodb.com Robert Stam
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: