Getting a null terminated string::view_or_value may copy unnecessarily

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Won't Fix
    • Priority: Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      string::view_or_value can be constructed from a const char*. This must be a null terminated string.

      The bsoncxx::string::view_or_value has a terminated method, which guarantees to return a view_or_value containing a null terminated representation of the string. This does not take into account the case where the view_or_value was constructed with a const char*, copying it when it really doesn't need to.

      We should add a boolean member to string::view_or_value to remember if it was constructed with a const char*, and if so, avoid copying when returning a null terminated view_or_value.

            Assignee:
            Kevin Albertson
            Reporter:
            Kevin Albertson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: