ObjectId could have a slightly smaller internal representation

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Done
    • Priority: Major - P3
    • 2.1
    • Affects Version/s: None
    • Component/s: BSON
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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.

            Assignee:
            Robert Stam (Inactive)
            Reporter:
            Robert Stam (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: