mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Replace std::string with StringRef in MessageInfo for macro capture
Because the macro name is compile-time constant, we do not have to worry about lifetimes and will avoid allocation in case of missing SSO or long macro name.
This commit is contained in:
parent
b93284716e
commit
78804ea304
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
MessageInfo::MessageInfo( std::string const& _macroName,
|
MessageInfo::MessageInfo( StringRef const& _macroName,
|
||||||
SourceLineInfo const& _lineInfo,
|
SourceLineInfo const& _lineInfo,
|
||||||
ResultWas::OfType _type )
|
ResultWas::OfType _type )
|
||||||
: macroName( _macroName ),
|
: macroName( _macroName ),
|
||||||
@ -35,7 +35,7 @@ namespace Catch {
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
Catch::MessageBuilder::MessageBuilder( std::string const& macroName,
|
Catch::MessageBuilder::MessageBuilder( StringRef const& macroName,
|
||||||
SourceLineInfo const& lineInfo,
|
SourceLineInfo const& lineInfo,
|
||||||
ResultWas::OfType type )
|
ResultWas::OfType type )
|
||||||
:m_info(macroName, lineInfo, type) {}
|
:m_info(macroName, lineInfo, type) {}
|
||||||
|
@ -12,15 +12,16 @@
|
|||||||
#include "catch_result_type.h"
|
#include "catch_result_type.h"
|
||||||
#include "catch_common.h"
|
#include "catch_common.h"
|
||||||
#include "catch_stream.h"
|
#include "catch_stream.h"
|
||||||
|
#include "catch_stringref.h"
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
struct MessageInfo {
|
struct MessageInfo {
|
||||||
MessageInfo( std::string const& _macroName,
|
MessageInfo( StringRef const& _macroName,
|
||||||
SourceLineInfo const& _lineInfo,
|
SourceLineInfo const& _lineInfo,
|
||||||
ResultWas::OfType _type );
|
ResultWas::OfType _type );
|
||||||
|
|
||||||
std::string macroName;
|
StringRef macroName;
|
||||||
std::string message;
|
std::string message;
|
||||||
SourceLineInfo lineInfo;
|
SourceLineInfo lineInfo;
|
||||||
ResultWas::OfType type;
|
ResultWas::OfType type;
|
||||||
@ -44,7 +45,7 @@ namespace Catch {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct MessageBuilder : MessageStream {
|
struct MessageBuilder : MessageStream {
|
||||||
MessageBuilder( std::string const& macroName,
|
MessageBuilder( StringRef const& macroName,
|
||||||
SourceLineInfo const& lineInfo,
|
SourceLineInfo const& lineInfo,
|
||||||
ResultWas::OfType type );
|
ResultWas::OfType type );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user