mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-26 07:16:10 +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 {
|
||||
|
||||
MessageInfo::MessageInfo( std::string const& _macroName,
|
||||
MessageInfo::MessageInfo( StringRef const& _macroName,
|
||||
SourceLineInfo const& _lineInfo,
|
||||
ResultWas::OfType _type )
|
||||
: macroName( _macroName ),
|
||||
@ -35,7 +35,7 @@ namespace Catch {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Catch::MessageBuilder::MessageBuilder( std::string const& macroName,
|
||||
Catch::MessageBuilder::MessageBuilder( StringRef const& macroName,
|
||||
SourceLineInfo const& lineInfo,
|
||||
ResultWas::OfType type )
|
||||
:m_info(macroName, lineInfo, type) {}
|
||||
|
@ -12,15 +12,16 @@
|
||||
#include "catch_result_type.h"
|
||||
#include "catch_common.h"
|
||||
#include "catch_stream.h"
|
||||
#include "catch_stringref.h"
|
||||
|
||||
namespace Catch {
|
||||
|
||||
struct MessageInfo {
|
||||
MessageInfo( std::string const& _macroName,
|
||||
MessageInfo( StringRef const& _macroName,
|
||||
SourceLineInfo const& _lineInfo,
|
||||
ResultWas::OfType _type );
|
||||
|
||||
std::string macroName;
|
||||
StringRef macroName;
|
||||
std::string message;
|
||||
SourceLineInfo lineInfo;
|
||||
ResultWas::OfType type;
|
||||
@ -44,7 +45,7 @@ namespace Catch {
|
||||
};
|
||||
|
||||
struct MessageBuilder : MessageStream {
|
||||
MessageBuilder( std::string const& macroName,
|
||||
MessageBuilder( StringRef const& macroName,
|
||||
SourceLineInfo const& lineInfo,
|
||||
ResultWas::OfType type );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user