mirror of
https://github.com/catchorg/Catch2.git
synced 2025-11-01 20:49:33 +01:00
This allows us to remove the lazy init checks, improving the inlining potential when retrieving current context, thus slightly improving the performance of assertions. **runtime difference** | --------- | Debug | Release | |:----------|------:|--------:| | Slow path | 1.01 | 0.98 | | Fast path | 1.02 | 1.02 | There is small slowdown in case of Release build + assertions taking the slow path, but 1) going through the slow path is rare 2) Given the code change, I believe this to be artifact of the optimizer in the old GCC version I am using locally.
25 lines
590 B
C++
25 lines
590 B
C++
|
|
// Copyright Catch2 Authors
|
|
// Distributed under the Boost Software License, Version 1.0.
|
|
// (See accompanying file LICENSE.txt or copy at
|
|
// https://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
// SPDX-License-Identifier: BSL-1.0
|
|
#include <catch2/internal/catch_context.hpp>
|
|
#include <catch2/internal/catch_random_number_generator.hpp>
|
|
|
|
namespace Catch {
|
|
|
|
Context Context::currentContext;
|
|
|
|
Context& getCurrentMutableContext() {
|
|
return Context::currentContext;
|
|
}
|
|
|
|
SimplePcg32& sharedRng() {
|
|
static SimplePcg32 s_rng;
|
|
return s_rng;
|
|
}
|
|
|
|
}
|