Version struct now uses char* for holding branch name

Since the info is constant, and the only use is to write it out during
runtime, there is no need for `std::string`.
This commit is contained in:
Martin Hořeňovský 2017-03-22 17:45:36 +01:00
parent e04dc5105b
commit d07999ddff
2 changed files with 7 additions and 7 deletions

View File

@ -15,7 +15,7 @@ namespace Catch {
Version( unsigned int _majorVersion, Version( unsigned int _majorVersion,
unsigned int _minorVersion, unsigned int _minorVersion,
unsigned int _patchNumber, unsigned int _patchNumber,
std::string const& _branchName, char const * const _branchName,
unsigned int _buildNumber ); unsigned int _buildNumber );
unsigned int const majorVersion; unsigned int const majorVersion;
@ -23,7 +23,7 @@ namespace Catch {
unsigned int const patchNumber; unsigned int const patchNumber;
// buildNumber is only used if branchName is not null // buildNumber is only used if branchName is not null
std::string const branchName; char const * const branchName;
unsigned int const buildNumber; unsigned int const buildNumber;
friend std::ostream& operator << ( std::ostream& os, Version const& version ); friend std::ostream& operator << ( std::ostream& os, Version const& version );

View File

@ -16,7 +16,7 @@ namespace Catch {
( unsigned int _majorVersion, ( unsigned int _majorVersion,
unsigned int _minorVersion, unsigned int _minorVersion,
unsigned int _patchNumber, unsigned int _patchNumber,
std::string const& _branchName, char const * const _branchName,
unsigned int _buildNumber ) unsigned int _buildNumber )
: majorVersion( _majorVersion ), : majorVersion( _majorVersion ),
minorVersion( _minorVersion ), minorVersion( _minorVersion ),
@ -29,8 +29,8 @@ namespace Catch {
os << version.majorVersion << '.' os << version.majorVersion << '.'
<< version.minorVersion << '.' << version.minorVersion << '.'
<< version.patchNumber; << version.patchNumber;
// branchName is never null -> 0th char is \0 if it is empty
if( !version.branchName.empty() ) { if (version.branchName[0]) {
os << '-' << version.branchName os << '-' << version.branchName
<< '.' << version.buildNumber; << '.' << version.buildNumber;
} }