Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-1269

BSON headers provide no way to give the length of a c string when used as a key or value

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 1.5.3
    • Component/s: Internal Client
    • Labels:
      None
    • Environment:
      All
    • Fully Compatible

      Consider the following code:

      const char kKey[] = "key";
      const char kValue[] = "value";
      someBSONObjBuilder.append(key, value);

      This is going to cause two calls to strlen which certainly don't need to be made, since the lengths of kKey and kValue are known at compile time. For such cases, it would be nice to have a mechanism to pass the already known size down to the BSONObjBuilder:

      someBSONObjBuilder.append(key, sizeof(key), value, sizeof(value));

      Similar overloads would need to be made for each type'd BSONObjBuilder::append(key, sizeof(key), T), and for BSONArrayBuilder.

            Assignee:
            andrew.morrow@mongodb.com Andrew Morrow (Inactive)
            Reporter:
            andrew.morrow@mongodb.com Andrew Morrow (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: