IDL parser's 'any' serialisation type results in extra data copy

XMLWordPrintableJSON

    • Server Programmability
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      The code that is generated when one specifies a type with serialisation type of 'any' looks like this:

              BSONArrayBuilder arrayBuilder(builder->subarrayStart(kWriteErrorsFieldName));
              for (const auto& item : _writeErrors.get()) {
                  const BSONObj localObject = item.serialize();
                  arrayBuilder.append(localObject);
              }
      

      This means that the serialiser method returns a free-standing BSONObject, which is then copied into the main builder.

      It would be more efficient if the serialiser generated looked like this in order to avoid the data copy:

              BSONArrayBuilder arrayBuilder(builder->subarrayStart(kWriteErrorsFieldName));
              for (const auto& item : _writeErrors.get()) {
                  item.serialize(arrayBuilder.subObjectStart(localObject));
              }
      

      This would require all places that use serialisation type of any currently to be changed so that their serialise method takes a BSONObjBuilder instead of returning BSONObj.

              Assignee:
              Unassigned
              Reporter:
              Kaloian Manassiev
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated: