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

Have pre-created BsonValue instances for common values

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Minor - P4 Minor - P4
    • 2.1
    • None
    • BSON
    • None

    Description

      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

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: