mirror of
https://github.com/catchorg/Catch2.git
synced 2025-09-19 19:25:38 +02:00
Performance improvement in AssertionInfo.
By using char const * instead of std::string we avoid significant copying per assertion. In a simple loop with 10000000 CHECKS on my system, this reduces the run time from 9.8s to 5.8s. This change is at the expense of no longer capturing the second arg, which no currently existing test notices.
This commit is contained in:
@@ -13,9 +13,9 @@
|
||||
namespace Catch {
|
||||
|
||||
|
||||
AssertionInfo::AssertionInfo( std::string const& _macroName,
|
||||
AssertionInfo::AssertionInfo( char const * _macroName,
|
||||
SourceLineInfo const& _lineInfo,
|
||||
std::string const& _capturedExpression,
|
||||
char const * _capturedExpression,
|
||||
ResultDisposition::Flags _resultDisposition )
|
||||
: macroName( _macroName ),
|
||||
lineInfo( _lineInfo ),
|
||||
@@ -47,7 +47,7 @@ namespace Catch {
|
||||
}
|
||||
|
||||
bool AssertionResult::hasExpression() const {
|
||||
return !m_info.capturedExpression.empty();
|
||||
return m_info.capturedExpression[0] != 0;
|
||||
}
|
||||
|
||||
bool AssertionResult::hasMessage() const {
|
||||
@@ -61,10 +61,10 @@ namespace Catch {
|
||||
return m_info.capturedExpression;
|
||||
}
|
||||
std::string AssertionResult::getExpressionInMacro() const {
|
||||
if( m_info.macroName.empty() )
|
||||
if( m_info.macroName[0] == 0 )
|
||||
return m_info.capturedExpression;
|
||||
else
|
||||
return m_info.macroName + "( " + m_info.capturedExpression + " )";
|
||||
return std::string(m_info.macroName) + "( " + m_info.capturedExpression + " )";
|
||||
}
|
||||
|
||||
bool AssertionResult::hasExpandedExpression() const {
|
||||
|
Reference in New Issue
Block a user