From 097dd7167279729a7df9f0cef67c549e70e74d4e Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 8 Dec 2019 19:43:02 +0100 Subject: Cleanup: Improve a few basic operator implementations --- src/FilePath.cpp | 5 +++-- 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; } -- cgit v1.2.1