catch3
Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.
Clonegit clone https://git.progmasoft.com/catch3
performance improvement - StringRef::operator=
- Commit
fe725648a7c288db925456ddc23cdd582f210d1b- Author
- Neal Coombes ·
- Parents
b0c379f62122
Changes
include/internal/catch_stringref.cpp | 4 ---- include/internal/catch_stringref.h | 9 ++++++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/include/internal/catch_stringref.cpp b/include/internal/catch_stringref.cpp index 5a15bbf6..49d9629f 100644 --- a/include/internal/catch_stringref.cpp +++ b/include/internal/catch_stringref.cpp @@ -17,10 +17,6 @@ namespace Catch { - auto StringRef::operator = ( StringRef other ) noexcept -> StringRef& { - swap( other ); - return *this; - } StringRef::operator std::string() const { return std::string( m_start, m_size ); } diff --git a/include/internal/catch_stringref.h b/include/internal/catch_stringref.h index fabd9ce8..2a9ad4c2 100644 --- a/include/internal/catch_stringref.h +++ b/include/internal/catch_stringref.h @@ -77,7 +77,14 @@ namespace Catch { delete[] m_data; } - auto operator = ( StringRef other ) noexcept -> StringRef&; + auto operator = ( StringRef const &other ) noexcept -> StringRef& { + delete[] m_data; + m_data = nullptr; + m_start = other.m_start; + m_size = other.m_size; + return *this; + } + operator std::string() const; void swap( StringRef& other ) noexcept;