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

View File

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