From 9f4c4777a5136a3e1f276398799961e9ccb4b572 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Sun, 8 Sep 2019 21:01:33 +0200 Subject: [PATCH] Remove (mostly) unused overloads of StringRef operator + --- include/internal/catch_assertionresult.cpp | 14 ++++++++++---- include/internal/catch_stringref.cpp | 14 -------------- include/internal/catch_stringref.h | 4 ---- 3 files changed, 10 insertions(+), 22 deletions(-) diff --git a/include/internal/catch_assertionresult.cpp b/include/internal/catch_assertionresult.cpp index a116bffa..608a9add 100644 --- a/include/internal/catch_assertionresult.cpp +++ b/include/internal/catch_assertionresult.cpp @@ -53,10 +53,16 @@ namespace Catch { } std::string AssertionResult::getExpression() const { - if( isFalseTest( m_info.resultDisposition ) ) - return "!(" + m_info.capturedExpression + ")"; - else - return static_cast(m_info.capturedExpression); + // Possibly overallocating by 3 characters should be basically free + std::string expr; expr.reserve(m_info.capturedExpression.size() + 3); + if (isFalseTest(m_info.resultDisposition)) { + expr += "!("; + } + expr += m_info.capturedExpression; + if (isFalseTest(m_info.resultDisposition)) { + expr += ')'; + } + return expr; } std::string AssertionResult::getExpressionInMacro() const { diff --git a/include/internal/catch_stringref.cpp b/include/internal/catch_stringref.cpp index 8e6741b1..0c617b49 100644 --- a/include/internal/catch_stringref.cpp +++ b/include/internal/catch_stringref.cpp @@ -76,20 +76,6 @@ namespace Catch { return m_start[index]; } - auto operator + ( StringRef const& lhs, StringRef const& rhs ) -> std::string { - std::string str; - str.reserve( lhs.size() + rhs.size() ); - str += lhs; - str += rhs; - return str; - } - auto operator + ( StringRef const& lhs, const char* rhs ) -> std::string { - return std::string( lhs ) + std::string( rhs ); - } - auto operator + ( char const* lhs, StringRef const& rhs ) -> std::string { - return std::string( lhs ) + std::string( rhs ); - } - auto operator << ( std::ostream& os, StringRef const& str ) -> std::ostream& { return os.write(str.currentData(), str.size()); } diff --git a/include/internal/catch_stringref.h b/include/internal/catch_stringref.h index b83e61bb..d2152eb9 100644 --- a/include/internal/catch_stringref.h +++ b/include/internal/catch_stringref.h @@ -115,10 +115,6 @@ namespace Catch { auto isSubstring() const noexcept -> bool; }; - auto operator + ( StringRef const& lhs, StringRef const& rhs ) -> std::string; - auto operator + ( StringRef const& lhs, char const* rhs ) -> std::string; - auto operator + ( char const* lhs, StringRef const& rhs ) -> std::string; - auto operator += ( std::string& lhs, StringRef const& sr ) -> std::string&; auto operator << ( std::ostream& os, StringRef const& sr ) -> std::ostream&;