On Wed, 16 Oct 2013 12:58:43 +0200, Sönke Ludwig wrote:

However, when implemented, it will not be a particularly efficient
operation (the whole BSON object needs to be written again into a new
buffer, which is O(n) + an allocation). Better is to make such
modifications on an AA before converting to BSON.

What about efficiency of adding new fields?
Is this code:

Bson obj = serializeToBson([
    "field1": serializeToBson(value1),
    "field2": serializeToBson(value2)
]);

more efficient then:

Bson obj = Bson.emptyObject;
obj.field1 = serializeToBson(value1);
obj.field2 = serializeToBson(value2);