Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMartin Hořeňovský2021-05-14 23:45:59 +0200
committerMartin Hořeňovský2021-05-14 23:45:59 +0200
commit61e16416a99fe4ba48c1adfc46082276433be6c0 (patch)
tree57e892cc11a0d80b0fa9fd90237fdc0d0a186d34
parent074017f5ad759328826a93dbea8ea41cc4d6808d (diff)
downloadcatch3-61e16416a99fe4ba48c1adfc46082276433be6c0.tar.gz
Pass other StringRef arguments by value instead of by-ref
Apart from being clearer, it also improves the overall codesize of the implementation library, and should improve the performance as well, by removing one level of indirection.
-rw-r--r--src/catch2/interfaces/catch_interfaces_capture.hpp2
-rw-r--r--src/catch2/internal/catch_assertion_handler.cpp6
-rw-r--r--src/catch2/internal/catch_assertion_handler.hpp6
-rw-r--r--src/catch2/internal/catch_run_context.cpp2
-rw-r--r--src/catch2/internal/catch_run_context.hpp2
-rw-r--r--src/catch2/internal/catch_test_case_registry_impl.cpp2
-rw-r--r--src/catch2/internal/catch_test_case_registry_impl.hpp2
-rw-r--r--src/catch2/internal/catch_test_registry.cpp2
-rw-r--r--src/catch2/internal/catch_test_registry.hpp6
-rw-r--r--src/catch2/matchers/internal/catch_matchers_combined_tu.cpp2
-rw-r--r--src/catch2/matchers/internal/catch_matchers_impl.hpp6
11 files changed, 19 insertions, 19 deletions
diff --git a/src/catch2/interfaces/catch_interfaces_capture.hpp b/src/catch2/interfaces/catch_interfaces_capture.hpp
index bfd0c023..b77b4d85 100644
--- a/src/catch2/interfaces/catch_interfaces_capture.hpp
+++ b/src/catch2/interfaces/catch_interfaces_capture.hpp
@@ -63,7 +63,7 @@ namespace Catch {
virtual void handleMessage
( AssertionInfo const& info,
ResultWas::OfType resultType,
- StringRef const& message,
+ StringRef message,
AssertionReaction& reaction ) = 0;
virtual void handleUnexpectedExceptionNotThrown
( AssertionInfo const& info,
diff --git a/src/catch2/internal/catch_assertion_handler.cpp b/src/catch2/internal/catch_assertion_handler.cpp
index 7774ca68..828aa7cd 100644
--- a/src/catch2/internal/catch_assertion_handler.cpp
+++ b/src/catch2/internal/catch_assertion_handler.cpp
@@ -18,7 +18,7 @@
namespace Catch {
AssertionHandler::AssertionHandler
- ( StringRef const& macroName,
+ ( StringRef macroName,
SourceLineInfo const& lineInfo,
StringRef capturedExpression,
ResultDisposition::Flags resultDisposition )
@@ -29,7 +29,7 @@ namespace Catch {
void AssertionHandler::handleExpr( ITransientExpression const& expr ) {
m_resultCapture.handleExpr( m_assertionInfo, expr, m_reaction );
}
- void AssertionHandler::handleMessage(ResultWas::OfType resultType, StringRef const& message) {
+ void AssertionHandler::handleMessage(ResultWas::OfType resultType, StringRef message) {
m_resultCapture.handleMessage( m_assertionInfo, resultType, message, m_reaction );
}
@@ -80,7 +80,7 @@ namespace Catch {
// This is the overload that takes a string and infers the Equals matcher from it
// The more general overload, that takes any string matcher, is in catch_capture_matchers.cpp
- void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str, StringRef const& matcherString ) {
+ void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str, StringRef matcherString ) {
handleExceptionMatchExpr( handler, Matchers::Equals( str ), matcherString );
}
diff --git a/src/catch2/internal/catch_assertion_handler.hpp b/src/catch2/internal/catch_assertion_handler.hpp
index 8e266ade..b7c7613e 100644
--- a/src/catch2/internal/catch_assertion_handler.hpp
+++ b/src/catch2/internal/catch_assertion_handler.hpp
@@ -32,7 +32,7 @@ namespace Catch {
public:
AssertionHandler
- ( StringRef const& macroName,
+ ( StringRef macroName,
SourceLineInfo const& lineInfo,
StringRef capturedExpression,
ResultDisposition::Flags resultDisposition );
@@ -49,7 +49,7 @@ namespace Catch {
}
void handleExpr( ITransientExpression const& expr );
- void handleMessage(ResultWas::OfType resultType, StringRef const& message);
+ void handleMessage(ResultWas::OfType resultType, StringRef message);
void handleExceptionThrownAsExpected();
void handleUnexpectedExceptionNotThrown();
@@ -64,7 +64,7 @@ namespace Catch {
auto allowThrows() const -> bool;
};
- void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str, StringRef const& matcherString );
+ void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str, StringRef matcherString );
} // namespace Catch
diff --git a/src/catch2/internal/catch_run_context.cpp b/src/catch2/internal/catch_run_context.cpp
index 127fc538..82235c4e 100644
--- a/src/catch2/internal/catch_run_context.cpp
+++ b/src/catch2/internal/catch_run_context.cpp
@@ -519,7 +519,7 @@ namespace Catch {
void RunContext::handleMessage(
AssertionInfo const& info,
ResultWas::OfType resultType,
- StringRef const& message,
+ StringRef message,
AssertionReaction& reaction
) {
m_reporter->assertionStarting( info );
diff --git a/src/catch2/internal/catch_run_context.hpp b/src/catch2/internal/catch_run_context.hpp
index 8819aa17..5f91ddda 100644
--- a/src/catch2/internal/catch_run_context.hpp
+++ b/src/catch2/internal/catch_run_context.hpp
@@ -54,7 +54,7 @@ namespace Catch {
void handleMessage
( AssertionInfo const& info,
ResultWas::OfType resultType,
- StringRef const& message,
+ StringRef message,
AssertionReaction& reaction ) override;
void handleUnexpectedExceptionNotThrown
( AssertionInfo const& info,
diff --git a/src/catch2/internal/catch_test_case_registry_impl.cpp b/src/catch2/internal/catch_test_case_registry_impl.cpp
index d142f045..f6808e4a 100644
--- a/src/catch2/internal/catch_test_case_registry_impl.cpp
+++ b/src/catch2/internal/catch_test_case_registry_impl.cpp
@@ -149,7 +149,7 @@ namespace {
m_testAsFunction();
}
- std::string extractClassName( StringRef const& classOrQualifiedMethodName ) {
+ std::string extractClassName( StringRef classOrQualifiedMethodName ) {
std::string className(classOrQualifiedMethodName);
if( startsWith( className, '&' ) )
{
diff --git a/src/catch2/internal/catch_test_case_registry_impl.hpp b/src/catch2/internal/catch_test_case_registry_impl.hpp
index f7fc37ef..383512af 100644
--- a/src/catch2/internal/catch_test_case_registry_impl.hpp
+++ b/src/catch2/internal/catch_test_case_registry_impl.hpp
@@ -64,7 +64,7 @@ namespace Catch {
};
- std::string extractClassName( StringRef const& classOrQualifiedMethodName );
+ std::string extractClassName( StringRef classOrQualifiedMethodName );
///////////////////////////////////////////////////////////////////////////
diff --git a/src/catch2/internal/catch_test_registry.cpp b/src/catch2/internal/catch_test_registry.cpp
index c4f26181..bb5d7810 100644
--- a/src/catch2/internal/catch_test_registry.cpp
+++ b/src/catch2/internal/catch_test_registry.cpp
@@ -17,7 +17,7 @@ namespace Catch {
return Detail::unique_ptr<ITestInvoker>( new TestInvokerAsFunction( testAsFunction ));
}
- AutoReg::AutoReg( Detail::unique_ptr<ITestInvoker> invoker, SourceLineInfo const& lineInfo, StringRef const& classOrMethod, NameAndTags const& nameAndTags ) noexcept {
+ AutoReg::AutoReg( Detail::unique_ptr<ITestInvoker> invoker, SourceLineInfo const& lineInfo, StringRef classOrMethod, NameAndTags const& nameAndTags ) noexcept {
CATCH_TRY {
getMutableRegistryHub()
.registerTest(
diff --git a/src/catch2/internal/catch_test_registry.hpp b/src/catch2/internal/catch_test_registry.hpp
index 9e8b5b6e..0a7b7474 100644
--- a/src/catch2/internal/catch_test_registry.hpp
+++ b/src/catch2/internal/catch_test_registry.hpp
@@ -46,15 +46,15 @@ Detail::unique_ptr<ITestInvoker> makeTestInvoker( void (C::*testAsMethod)() ) {
}
struct NameAndTags {
- NameAndTags(StringRef const& name_ = StringRef(),
- StringRef const& tags_ = StringRef()) noexcept:
+ NameAndTags(StringRef name_ = StringRef(),
+ StringRef tags_ = StringRef()) noexcept:
name(name_), tags(tags_) {}
StringRef name;
StringRef tags;
};
struct AutoReg : Detail::NonCopyable {
- AutoReg( Detail::unique_ptr<ITestInvoker> invoker, SourceLineInfo const& lineInfo, StringRef const& classOrMethod, NameAndTags const& nameAndTags ) noexcept;
+ AutoReg( Detail::unique_ptr<ITestInvoker> invoker, SourceLineInfo const& lineInfo, StringRef classOrMethod, NameAndTags const& nameAndTags ) noexcept;
};
} // end namespace Catch
diff --git a/src/catch2/matchers/internal/catch_matchers_combined_tu.cpp b/src/catch2/matchers/internal/catch_matchers_combined_tu.cpp
index 7104e4c8..f3befb02 100644
--- a/src/catch2/matchers/internal/catch_matchers_combined_tu.cpp
+++ b/src/catch2/matchers/internal/catch_matchers_combined_tu.cpp
@@ -29,7 +29,7 @@ namespace Catch {
// This is the general overload that takes a any string matcher
// There is another overload, in catch_assertionhandler.h/.cpp, that only takes a string and infers
// the Equals matcher (so the header does not mention matchers)
- void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher, StringRef const& matcherString ) {
+ void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher, StringRef matcherString ) {
std::string exceptionMessage = Catch::translateActiveException();
MatchExpr<std::string, StringMatcher const&> expr( std::move(exceptionMessage), matcher, matcherString );
handler.handleExpr( expr );
diff --git a/src/catch2/matchers/internal/catch_matchers_impl.hpp b/src/catch2/matchers/internal/catch_matchers_impl.hpp
index 5a5448da..3b154746 100644
--- a/src/catch2/matchers/internal/catch_matchers_impl.hpp
+++ b/src/catch2/matchers/internal/catch_matchers_impl.hpp
@@ -19,7 +19,7 @@ namespace Catch {
MatcherT const& m_matcher;
StringRef m_matcherString;
public:
- MatchExpr( ArgT && arg, MatcherT const& matcher, StringRef const& matcherString )
+ MatchExpr( ArgT && arg, MatcherT const& matcher, StringRef matcherString )
: ITransientExpression{ true, matcher.match( arg ) }, // not forwarding arg here on purpose
m_arg( std::forward<ArgT>(arg) ),
m_matcher( matcher ),
@@ -43,10 +43,10 @@ namespace Catch {
using StringMatcher = Matchers::MatcherBase<std::string>;
- void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher, StringRef const& matcherString );
+ void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher, StringRef matcherString );
template<typename ArgT, typename MatcherT>
- auto makeMatchExpr( ArgT && arg, MatcherT const& matcher, StringRef const& matcherString ) -> MatchExpr<ArgT, MatcherT> {
+ auto makeMatchExpr( ArgT && arg, MatcherT const& matcher, StringRef matcherString ) -> MatchExpr<ArgT, MatcherT> {
return MatchExpr<ArgT, MatcherT>( std::forward<ArgT>(arg), matcher, matcherString );
}