From a156440b19c1103419b6e4d3ebbfe3c7ddb948dc 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:08:37 +0200 Subject: [PATCH] Reinline some StringRef methods with trivial bodies --- include/internal/catch_stringref.cpp | 8 -------- include/internal/catch_stringref.h | 10 ++++++++-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/include/internal/catch_stringref.cpp b/include/internal/catch_stringref.cpp index 0c617b49..b46414ac 100644 --- a/include/internal/catch_stringref.cpp +++ b/include/internal/catch_stringref.cpp @@ -22,10 +22,6 @@ namespace Catch { : StringRef( rawChars, static_cast(std::strlen(rawChars) ) ) {} - StringRef::operator std::string() const { - return std::string( m_start, m_size ); - } - void StringRef::swap( StringRef& other ) noexcept { std::swap( m_start, other.m_start ); std::swap( m_size, other.m_size ); @@ -72,10 +68,6 @@ namespace Catch { return !operator==( other ); } - auto StringRef::operator[](size_type index) const noexcept -> char { - return m_start[index]; - } - 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 d2152eb9..a45147da 100644 --- a/include/internal/catch_stringref.h +++ b/include/internal/catch_stringref.h @@ -10,6 +10,7 @@ #include #include #include +#include namespace Catch { @@ -79,7 +80,9 @@ namespace Catch { return *this; } - explicit operator std::string() const; + explicit operator std::string() const { + return std::string(m_start, m_size); + } void swap( StringRef& other ) noexcept; @@ -87,7 +90,10 @@ namespace Catch { auto operator == ( StringRef const& other ) const noexcept -> bool; auto operator != ( StringRef const& other ) const noexcept -> bool; - auto operator[] ( size_type index ) const noexcept -> char; + auto operator[] ( size_type index ) const noexcept -> char { + assert(index < m_size); + return m_start[index]; + } public: // named queries auto empty() const noexcept -> bool {