Skip to content

Commit

Permalink
Use move ctor instead of copy ctor in stringOrDefault
Browse files Browse the repository at this point in the history
  • Loading branch information
PragmaTwice authored Mar 13, 2024
1 parent 9065a0a commit 7c6f9f1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion libsolutil/Assertions.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <libsolutil/Exceptions.h>

#include <string>
#include <utility>

namespace solidity::util
{
Expand Down Expand Up @@ -69,7 +70,7 @@ inline std::string stringOrDefault(std::string _string, std::string _defaultStri
{
// NOTE: Putting this in a function rather than directly in a macro prevents the string from
// being evaluated multiple times if it's not just a literal.
return (!_string.empty() ? _string : _defaultString);
return (!_string.empty() ? std::move(_string) : std::move(_defaultString));
}

}
Expand Down

0 comments on commit 7c6f9f1

Please sign in to comment.