diff options
| author | Martin Hořeňovský | 2025-09-23 15:23:58 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2025-09-27 13:24:46 +0200 |
| commit | 756ae05d307168eaa27bd904dbd8e591a6406889 (patch) | |
| tree | e64236a5fde23db97284d9894348af6292676db2 /src/catch2/interfaces/catch_interfaces_capture.cpp | |
| parent | a2e41916f2cc0adbd27fc3d9cb89e9615fea1ad8 (diff) | |
| download | catch3-756ae05d307168eaa27bd904dbd8e591a6406889.tar.gz | |
Inline the `getResultCapture` helper into header.
We still keep the error check in the function, but hide it in an
outlined function inside a .cpp file, to promote inlining of the
retrieval part.
In the future, we should explore two things
1) Skipping over the context retrieval here, allowing direct access.
I currently do not see a way to do this while keeping the
"greppability" of mutable vs immutable accesses that is there now,
but it would help a lot when inlining is not enabled.
2) Removing the error check, to make the function trivially inlinable,
and without branches.
**runtime difference**
| --------- | Debug | Release |
|:----------|------:|--------:|
| Slow path | 0.98 | 1.07 |
| Fast path | 1.04 | 1.08 |
We lost bit of performance on the assertion slow path in debug mode,
but together with the previous commit, it comes out at net zero.
For other combinations, we see 5-10% perf improvement across the
two commits.
Diffstat (limited to 'src/catch2/interfaces/catch_interfaces_capture.cpp')
| -rw-r--r-- | src/catch2/interfaces/catch_interfaces_capture.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/catch2/interfaces/catch_interfaces_capture.cpp b/src/catch2/interfaces/catch_interfaces_capture.cpp index 9b40ee5d..492c5bd9 100644 --- a/src/catch2/interfaces/catch_interfaces_capture.cpp +++ b/src/catch2/interfaces/catch_interfaces_capture.cpp @@ -7,7 +7,14 @@ // SPDX-License-Identifier: BSL-1.0 #include <catch2/interfaces/catch_interfaces_capture.hpp> +#include <catch2/internal/catch_enforce.hpp> namespace Catch { + namespace Detail { + void missingCaptureInstance() { + CATCH_INTERNAL_ERROR( "No result capture instance" ); + } + } // namespace Detail + IResultCapture::~IResultCapture() = default; -} +} // namespace Catch |