mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 20:27:11 +01:00 
			
		
		
		
	performance improvement - StringRef::operator=
inlined and reduced data copy in half. Further work on #1086. Brings test from 0m44.942s to 0m37.913.
This commit is contained in:
		| @@ -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 ); | ||||
|     } | ||||
|   | ||||
| @@ -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; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Neal Coombes
					Neal Coombes