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

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

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 3.1.2
    • None
    • Internal Code
    • None
    • Fully Compatible
    • Quint Iteration 3.1.2

    Description

      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.

      Attachments

        Activity

          People

            rassi J Rassi
            rassi J Rassi
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: