Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

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`.
Commit
d07999ddff794a7ce58e761d59d379d29503e97e
Author
Martin Hořeňovský ·
Parents
e04dc5105b53

Files · Download .tar.gz

Changes

 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;
     }