Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-17803

Constructing an error StatusWith should not require copy of Status/std::string

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.1.2
    • Affects Version/s: None
    • Component/s: Internal Code
    • None
    • Fully Compatible
    • Quint Iteration 3.1.2
    • None
    • 0
    • None
    • None
    • None
    • None
    • None
    • None

      The following StatusWith constructors are currently available for construction of an error StatusWith:

              StatusWith( ErrorCodes::Error code, const std::string& reason, int location = 0 )
                  : _status( Status( code, reason, location ) ) {
              }
      
              StatusWith( const Status& status )
                  : _status( status ) {
              }
      

      These constructors should take their const-reference arguments by value instead, to avoid unnecessary copies when a temporary is passed:

              StatusWith( ErrorCodes::Error code, std::string reason, int location = 0 )
                  : _status( Status( code, std::move( reason ), location ) ) {
              }
      
              StatusWith( Status status )
                  : _status( std::move( status ) ) {
              }
      

      Changing the three-argument StatusWith constructor requires also changing the respective three-argument Status constructor.

            Assignee:
            rassi J Rassi (Inactive)
            Reporter:
            rassi J Rassi (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: