Skip to content

Commit 3a06949

Browse files
committed
bson_concat instead of iter for writeConcernError
bson_concat is a more straight forward memcpy than using bson_value with iteration. Closes #147
1 parent 4d6caf2 commit 3a06949

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/mongoc/mongoc-write-command.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,15 +1155,14 @@ _mongoc_write_result_merge (mongoc_write_result_t *result, /* IN */
11551155

11561156
if (bson_iter_init_find (&iter, reply, "writeConcernError") &&
11571157
BSON_ITER_HOLDS_DOCUMENT (&iter)) {
1158-
bson_iter_t citer;
11591158

1160-
bson_iter_recurse (&iter, &citer);
1161-
while (bson_iter_next (&citer)) {
1162-
const bson_value_t *value;
1159+
uint32_t len;
1160+
const uint8_t *data;
1161+
bson_t write_concern_error;
11631162

1164-
value = bson_iter_value (&citer);
1165-
BSON_APPEND_VALUE (&result->writeConcernError, bson_iter_key (&citer), value);
1166-
}
1163+
bson_iter_document (&iter, &len, &data);
1164+
bson_init_static (&write_concern_error, data, len);
1165+
bson_concat (&result->writeConcernError, &write_concern_error);
11671166
}
11681167

11691168
switch (command->type) {

0 commit comments

Comments
 (0)