Skip to content

Commit

Permalink
Merge pull request ethereum#14936 from PragmaTwice/add-move-to-string…
Browse files Browse the repository at this point in the history
…-or-default

Use move ctor instead of copy ctor in stringOrDefault
  • Loading branch information
cameel authored Mar 13, 2024
2 parents ab55b0a + 7c6f9f1 commit 0dce029
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 0dce029

Please sign in to comment.