Avoid string length calculations for bson_append calls

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Fixed
    • Priority: Minor - P4
    • 2.3.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      Various bson_append calls throughout the driver specify -1 as the key length, which directs libbson to call strlen() on the function argument. For situations where we know the string length (e.g. string literal), we should explicitly specify the string length.

      The BSON_APPEND macros discussed in the libbson documentation might also be reasonable if we can rely on the compiler to optimize strlen() calls for string literals.

            Assignee:
            Pauline Vos
            Reporter:
            Jeremy Mikola (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: