From c5037743e6834c3abcf942cb02a29c6119ecc699 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Wed, 29 Jul 2020 21:29:38 +0200 Subject: [PATCH] Avoid copying SectionInfo while construction Section --- src/catch2/internal/catch_section.cpp | 10 ++++++---- src/catch2/internal/catch_section.hpp | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/catch2/internal/catch_section.cpp b/src/catch2/internal/catch_section.cpp index 52361584..9db6ca9f 100644 --- a/src/catch2/internal/catch_section.cpp +++ b/src/catch2/internal/catch_section.cpp @@ -10,12 +10,14 @@ #include #include +#include + namespace Catch { - Section::Section( SectionInfo const& info ) - : m_info( info ), - m_sectionIncluded( getResultCapture().sectionStarted( m_info, m_assertions ) ) - { + Section::Section( SectionInfo&& info ): + m_info( std::move( info ) ), + m_sectionIncluded( + getResultCapture().sectionStarted( m_info, m_assertions ) ) { // Non-"included" sections will not use the timing information // anyway, so don't bother with the potential syscall. if (m_sectionIncluded) { diff --git a/src/catch2/internal/catch_section.hpp b/src/catch2/internal/catch_section.hpp index 997e7069..bdaf54af 100644 --- a/src/catch2/internal/catch_section.hpp +++ b/src/catch2/internal/catch_section.hpp @@ -19,7 +19,7 @@ namespace Catch { class Section : NonCopyable { public: - Section( SectionInfo const& info ); + Section( SectionInfo&& info ); ~Section(); // This indicates whether the section should be executed or not