Have pre-created BsonValue instances for common values

XMLWordPrintableJSON

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

      We could reduce pressure on the GC by having pre-created instances of many commonly used BsonValues. For example:

      BsonBoolean: true, false
      BsonDouble, -100.0 to 100.0 in 1.0 increments
      BsonInt32/BsonInt64: -100 to 100
      BsonString: empty string

      The way these would be taken advantage of would be in the implicit conversions from primitive types to BsonValues. For example:

      BsonValue a = true; // implicit conversion returns existing BsonBoolean instance for True
      BsonValue b = 10.0; // implicit conversion returns existing BsonDouble instance for 10.0
      BsonValue c = -1; // implicit conversion returns existing BsonInt32 instance for -1
      

            Assignee:
            Robert Stam
            Reporter:
            Robert Stam
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: