reapack

Package manager for REAPER
Log | Files | Refs | Submodules | README | LICENSE

commit ee7a9d94e905d4f45f1d24514c70d8c4e320dafd
parent 82e9c805798b511c7dc640500d375eec8eeb5f4c
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Sat,  8 Oct 2016 19:43:31 -0400

version: copy only the required stuff in the copy constructor

I don't see why the other things should be copied as they are unused
in the non-pointer usage of this class from the registry
(and we never copy from the pointer anyway)

Diffstat:
Msrc/version.cpp | 5++---
Msrc/version.hpp | 2+-
Mtest/version.cpp | 21+++++++++------------
3 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/src/version.cpp b/src/version.cpp @@ -39,10 +39,9 @@ Version::Version(const string &str, const Package *pkg) parse(str); } -Version::Version(const Version &o, const Package *pkg) +Version::Version(const Version &o) : m_name(o.m_name), m_segments(o.m_segments), m_stable(o.m_stable), - m_author(o.m_author), m_changelog(o.m_changelog), m_time(o.m_time), - m_package(pkg) + m_author(o.m_author), m_package(nullptr) { } diff --git a/src/version.hpp b/src/version.hpp @@ -35,7 +35,7 @@ class Version { public: Version(); Version(const std::string &, const Package * = nullptr); - Version(const Version &, const Package * = nullptr); + Version(const Version &); ~Version(); void parse(const std::string &); diff --git a/test/version.cpp b/test/version.cpp @@ -309,16 +309,13 @@ TEST_CASE("copy version constructor", M) { original.setChangelog("Initial release"); original.setTime("2016-02-12T01:16:40Z"); - const Version copy1(original); - REQUIRE(copy1.name() == "1.1test"); - REQUIRE(copy1.size() == original.size()); - REQUIRE(copy1.isStable() == original.isStable()); - REQUIRE(copy1.author() == original.author()); - REQUIRE(copy1.changelog() == original.changelog()); - REQUIRE(copy1.time() == original.time()); - REQUIRE(copy1.package() == nullptr); - REQUIRE(copy1.sources().empty()); - - const Version copy2(original, &pkg); - REQUIRE(copy2.package() == &pkg); + const Version copy(original); + REQUIRE(copy.name() == "1.1test"); + REQUIRE(copy.size() == original.size()); + REQUIRE(copy.isStable() == original.isStable()); + REQUIRE(copy.author() == original.author()); + REQUIRE(copy.changelog().empty()); + REQUIRE_FALSE(copy.time().isValid()); + REQUIRE(copy.package() == nullptr); + REQUIRE(copy.sources().empty()); }