gnucash stable: Multiple changes pushed
Christopher Lam
clam at code.gnucash.org
Sun Mar 17 11:09:07 EDT 2024
Updated via https://github.com/Gnucash/gnucash/commit/9cc31f32 (commit)
via https://github.com/Gnucash/gnucash/commit/ba403e4a (commit)
from https://github.com/Gnucash/gnucash/commit/9a39b3cd (commit)
commit 9cc31f329cfb3ae4c6691276b6932d515d0943ef
Merge: 9a39b3cd69 ba403e4a7c
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sun Mar 17 17:21:38 2024 +0800
Merge branch 'faster-uuid-gen' into stable #1887
commit ba403e4a7cd2ff5a4d9e4c669ce71c6260fe21a3
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sat Mar 16 11:25:39 2024 +0800
[guid.hpp] GUID::from_string and is_valid_string takes a const char*
boost::uuids::string_generator has operator()(const char*).
thus we can avoid allocating std::string, with a consistent 4% speedup
diff --git a/libgnucash/engine/guid.cpp b/libgnucash/engine/guid.cpp
index 55aade3cfd..48894640e2 100644
--- a/libgnucash/engine/guid.cpp
+++ b/libgnucash/engine/guid.cpp
@@ -331,8 +331,10 @@ GUID::to_string () const noexcept
}
GUID
-GUID::from_string (std::string const & str)
+GUID::from_string (const char* str)
{
+ if (!str)
+ throw guid_syntax_exception {};
try
{
static boost::uuids::string_generator strgen;
@@ -345,7 +347,7 @@ GUID::from_string (std::string const & str)
}
bool
-GUID::is_valid_guid (std::string const & str)
+GUID::is_valid_guid (const char* str)
{
try
{
diff --git a/libgnucash/engine/guid.hpp b/libgnucash/engine/guid.hpp
index 8b72e34348..7a883ecd9b 100644
--- a/libgnucash/engine/guid.hpp
+++ b/libgnucash/engine/guid.hpp
@@ -24,6 +24,7 @@
#include <boost/uuid/uuid.hpp>
#include <stdexcept>
+#include <string>
#include "guid.h"
@@ -48,8 +49,10 @@ struct GUID
operator GncGUID () const noexcept;
static GUID create_random () noexcept;
static GUID const & null_guid () noexcept;
- static GUID from_string (std::string const &);
- static bool is_valid_guid (std::string const &);
+ static GUID from_string (const char*);
+ static GUID from_string (std::string const& s) { return from_string (s.c_str()); };
+ static bool is_valid_guid (const char*);
+ static bool is_valid_guid (std::string const &s) { return is_valid_guid (s.c_str()); };
std::string to_string () const noexcept;
auto begin () const noexcept -> decltype (implementation.begin ());
auto end () const noexcept -> decltype (implementation.end ());
Summary of changes:
libgnucash/engine/guid.cpp | 6 ++++--
libgnucash/engine/guid.hpp | 7 +++++--
2 files changed, 9 insertions(+), 4 deletions(-)
More information about the gnucash-changes
mailing list