diff options
| author | Martin Hořeňovský | 2023-12-27 21:43:40 +0100 |
|---|---|---|
| committer | Martin Hořeňovský | 2023-12-27 21:43:49 +0100 |
| commit | b52d97855d794175e69abc6f0eceee9ec3c1bd0e (patch) | |
| tree | 58a39440729f19ff1f39da58286c64dc3bcdd31a /src/catch2/internal/catch_textflow.cpp | |
| parent | eaafd076743407e930a11297425f33c1f78220b0 (diff) | |
| download | catch3-b52d97855d794175e69abc6f0eceee9ec3c1bd0e.tar.gz | |
Move-enable various parts of TextFlow
This removes about 200 pointless copies from printing the help
message (the original motivation for the change), and also nicely
improves performance of the various reporters that depend on
TextFlow.
Diffstat (limited to 'src/catch2/internal/catch_textflow.cpp')
| -rw-r--r-- | src/catch2/internal/catch_textflow.cpp | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/src/catch2/internal/catch_textflow.cpp b/src/catch2/internal/catch_textflow.cpp index 7eac9732..857fd2b9 100644 --- a/src/catch2/internal/catch_textflow.cpp +++ b/src/catch2/internal/catch_textflow.cpp @@ -233,23 +233,36 @@ namespace Catch { return os; } - Columns Column::operator+( Column const& other ) { + Columns operator+(Column const& lhs, Column const& rhs) { Columns cols; - cols += *this; - cols += other; + cols += lhs; + cols += rhs; return cols; } - - Columns& Columns::operator+=( Column const& col ) { - m_columns.push_back( col ); - return *this; + Columns operator+(Column&& lhs, Column&& rhs) { + Columns cols; + cols += CATCH_MOVE( lhs ); + cols += CATCH_MOVE( rhs ); + return cols; } - Columns Columns::operator+( Column const& col ) { - Columns combined = *this; - combined += col; + Columns& operator+=(Columns& lhs, Column const& rhs) { + lhs.m_columns.push_back( rhs ); + return lhs; + } + Columns& operator+=(Columns& lhs, Column&& rhs) { + lhs.m_columns.push_back( CATCH_MOVE(rhs) ); + return lhs; + } + Columns operator+( Columns const& lhs, Column const& rhs ) { + auto combined( lhs ); + combined += rhs; return combined; } + Columns operator+( Columns&& lhs, Column&& rhs ) { + lhs += CATCH_MOVE( rhs ); + return CATCH_MOVE( lhs ); + } } // namespace TextFlow } // namespace Catch |