.\" Man page generated from reStructuredText. . .TH "BSON_PERFORMANCE" "3" "May 23, 2017" "1.6.3" "Libbson" .SH NAME bson_performance \- Performance Notes . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .SH ARRAY ELEMENT KEY BUILDING .sp When writing marshaling layers between higher level languages and Libbson, you will eventually need to build keys for array elements. Each element in a BSON array has a monotonic string key like \fB"0"\fP, \fB"1"\fP, etc. Using \fBsnprintf()\fP and others tend to be rather slow on most \fBlibc\fP implementations. Therefore, Libbson provides \fBbson_uint32_to_string()\fP to improve this. Using this function allows an internal fast path to be used for numbers less than 1000 which is the vast majority of arrays. If the key is larger than that, a fallback of \fBsnprintf()\fP will be used. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C char str[16]; const char *key; uint32_t i; for (i = 0; i < 10; i++) { bson_uint32_to_string (i, &key, str, sizeof str); printf ("Key: %s\en", key); } .ft P .fi .UNINDENT .UNINDENT .sp For more information, see \fBbson_uint32_to_string()\fP\&. .SH AUTHOR MongoDB, Inc .SH COPYRIGHT 2017, MongoDB, Inc .\" Generated by docutils manpage writer. .