Avoid string copies for Document field lookups

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Fixed
    • Priority: Minor - P4
    • 8.2.0-rc0
    • Affects Version/s: None
    • Component/s: Query Execution
    • None
    • Query Execution
    • Fully Compatible
    • QE 2025-05-12
    • None
    • 3
    • TBD
    • None
    • None
    • None
    • None
    • None
    • None
    • 0

      In Document[key] / Document::getField(key), we have this code:

          template <typename T>
          Value operator[](T key) const {
              return getField(key);
          }
          template <typename T>
          Value getField(T key) const {
              return storage().getField(key);
          }
      

      This is creating copies of key, which could be an issue when called with expensive-to-copy T values like std::string
      I added some static_assert(!std::is_same_v<T, std::string>); for fun in there, and then compilation fails. This means we are calling these functions with std::string arguments from some call sites.
      We should fix this to avoid any unnecessary string copies here.

            Assignee:
            Jan Steemann
            Reporter:
            Jan Steemann
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: