[SERVER-17803] Constructing an error StatusWith should not require copy of Status/std::string Created: 30/Mar/15  Updated: 19/Sep/15  Resolved: 08/Apr/15

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: 3.1.2

Type: Improvement Priority: Major - P3
Reporter: J Rassi Assignee: J Rassi
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Sprint: Quint Iteration 3.1.2
Participants:

 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.



 Comments   
Comment by Githook User [ 08/Apr/15 ]

Author:

{u'username': u'jrassi', u'name': u'Jason Rassi', u'email': u'rassi@10gen.com'}

Message: SERVER-17803 Constructing StatusWith shouldn't require Status copy
Branch: master
https://github.com/mongodb/mongo/commit/f02ec5f81009b9131e4e0968a76a47891704a67a

Comment by Githook User [ 08/Apr/15 ]

Author:

{u'username': u'jrassi', u'name': u'Jason Rassi', u'email': u'rassi@10gen.com'}

Message: SERVER-17803 Constructing Status shouldn't require error string copy

Removes 'const char*' Status constructor.
Branch: master
https://github.com/mongodb/mongo/commit/0516e5cd50c59a205951b6b2188fcad756deb46e

Generated at Thu Feb 08 03:45:37 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.