diff options
author | David Robillard <d@drobilla.net> | 2019-12-08 19:43:02 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2019-12-08 21:08:26 +0100 |
commit | 097dd7167279729a7df9f0cef67c549e70e74d4e (patch) | |
tree | 3d7746c36c9c9d7aa389329710787f9a8af746b1 | |
parent | 9a2c78b83adfcd654539a89f9a7b00ce47ccdd71 (diff) | |
download | ingen-097dd7167279729a7df9f0cef67c549e70e74d4e.tar.gz ingen-097dd7167279729a7df9f0cef67c549e70e74d4e.tar.bz2 ingen-097dd7167279729a7df9f0cef67c549e70e74d4e.zip |
Cleanup: Improve a few basic operator implementations
-rw-r--r-- | src/FilePath.cpp | 5 | ||||
-rw-r--r-- | src/URI.cpp | 7 |
2 files changed, 8 insertions, 4 deletions
diff --git a/src/FilePath.cpp b/src/FilePath.cpp index ad739e95..d16c133c 100644 --- a/src/FilePath.cpp +++ b/src/FilePath.cpp @@ -44,13 +44,14 @@ FilePath::operator=(FilePath&& path) noexcept FilePath& FilePath::operator=(string_type&& str) { - return *this = FilePath(std::move(str)); + _str = std::move(str); + return *this; } FilePath& FilePath::operator/=(const FilePath& path) { - const FilePath::string_type str = path.string(); + const FilePath::string_type& str = path.string(); if (!_str.empty() && !is_sep(_str.back()) && !str.empty() && !is_sep(str.front())) { _str += preferred_separator; diff --git a/src/URI.cpp b/src/URI.cpp index 67a26ee9..f7b64209 100644 --- a/src/URI.cpp +++ b/src/URI.cpp @@ -81,8 +81,11 @@ URI::URI(const URI& uri) URI& URI::operator=(const URI& uri) { - serd_node_free(&_node); - _node = serd_node_new_uri(&uri._uri, nullptr, &_uri); + if (&uri != this) { + serd_node_free(&_node); + _node = serd_node_new_uri(&uri._uri, nullptr, &_uri); + } + return *this; } |