From d07999ddff794a7ce58e761d59d379d29503e97e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Wed, 22 Mar 2017 17:45:36 +0100 Subject: [PATCH] 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`. --- include/internal/catch_version.h | 4 ++-- include/internal/catch_version.hpp | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/internal/catch_version.h b/include/internal/catch_version.h index 09032d68..9f6bc283 100644 --- a/include/internal/catch_version.h +++ b/include/internal/catch_version.h @@ -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 ); diff --git a/include/internal/catch_version.hpp b/include/internal/catch_version.hpp index 2af86348..4ce90645 100644 --- a/include/internal/catch_version.hpp +++ b/include/internal/catch_version.hpp @@ -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; }