Commit Graph
20 Commits
Author SHA1 Message Date
Christopher Lam 349c208a6c [guid.cpp] GncGUID* avoids temporary gnc::GUID, and better hash 2025-12-09 06:16:31 +08:00
Christopher Lam 722a455593 [guid.cpp] string->guid should disallow 'g' char
off-by-1 error in alpha test. only 'a'-'f' should be allowed.
2025-11-30 20:51:33 +08:00
Christopher Lam cdb9dfa0ee [guid.cpp] fast_string_to_guid: -1<<4 is UB, fix UB
when parsing invalid chars, hi|lo would return -1. convert to unsigned
to avoid UB.
2025-11-30 20:51:04 +08:00
Christopher Lam 3e4e334944 [guid.cpp] string->guid: parse into uuid data, avoids memcpy 2025-11-30 20:49:40 +08:00
Christopher Lam 534bea748f [guid.cpp] Specialise guid<->32-byte string
- string->guid has branch-lite unrollable loop, fallback to slow
  boost parser
- guid->string uses lookup table
- avoids creating several temporary heap-allocated std::strings
2025-11-29 07:58:04 +08:00
Christopher Lam 3c5a1801e2 [guid.cpp] fix guid==nullptr comparison retvals
- if guid_1 guid_2 are both null they should return int(0) or bool(true)
2025-11-29 07:58:04 +08:00
Christopher Lam dab32807ef [engine/*.cpp] NULL -> nullptr changes
It's the done thing
2024-04-02 21:09:39 +08:00
Christopher Lam ba403e4a7c [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
2024-03-17 09:07:59 +08:00
John Ralls 73dec63d1d Eliminate a frequent exception in guid_from_string
By not trying to construct a GUID from an empty string.
2023-08-10 14:05:10 -07:00
Richard Cohen 3abc9a5558 Refactor: Remove some unnecessary uses of memcpy
- Also, remove unnecessary "static" in gnucash-style.c

The second one in guid.cpp is UB:

libgnucash/engine/guid.cpp:137:5: warning: undefined behavior, source object type 'const gnc::GUID' is not TriviallyCopyable [bugprone-undefined-memory-manipulation]
        memcpy (&target, &source, sizeof (GncGUID));
        ^
2023-06-15 11:10:58 +01:00
Richard Cohen eb2d5df778 Refactor: DEFINE_BOXED GncGUID 2023-05-21 15:20:18 +01:00
John Ralls 00c560d8f5 Move operator==(const GncGUID&, const GncGUID&) to guid.[ch]pp. 2023-03-18 13:53:49 -07:00
Richard Cohen c819b03a17 Remove some unused variables - leave the side effect 2023-02-06 14:19:29 +00:00
Richard Cohen ea2d3be217 Remove some unused variables with obviously no side effects 2023-02-06 14:19:22 +00:00
Richard Cohen 1cec0cb3f3 Use internal extern "C" { ... } for C++
- removes warnings compiling swig engine
...
[ 10%] Generating swig-engine.cpp
.../libgnucash/engine/engine-helpers.h:31: Warning 313: Unrecognized extern type "C++".
.../libgnucash/engine/gnc-date.h:83: Warning 313: Unrecognized extern type "C++".
.../libgnucash/engine/qofquery.h:90: Warning 302: Identifier 'QofQuery' redefined (ignored),
.../libgnucash/engine/gnc-option.hpp:55: Warning 302: previous definition of 'QofQuery'.
.../libgnucash/engine/gnc-commodity.h:56: Warning 313: Unrecognized extern type "C++".
.../libgnucash/engine/gncBusiness.h:40: Warning 313: Unrecognized extern type "C++".
.../libgnucash/engine/gncEntry.h:37: Warning 313: Unrecognized extern type "C++".
2023-01-23 18:40:01 +00:00
John Ralls 36d729652b Speed up GUID equality comparison. 2018-03-06 09:48:38 -08:00
John Ralls 91727525b9 Enforce -Werror on C++ files and fix resulting errors. 2017-12-26 15:18:43 -08:00
lmat 4a88f05d11 kvp string: allocate enough space
We need to allocate enough space for the terminating null character.
Also, I double-checked the documents for std::basic_string::c_str () and
verified that it does guarantee the terminating null, so I put a comment
in the code that depends on that.
2017-12-21 07:39:33 -05:00
lmat b3667c76fc Implement flat bayes kvp
The bayes data are stored in the KVP store. Before this commit, they are
stored under /import-map-bayes/<token>/<account guid>/count (where count
is the datum that "matters" in bayes matching).

The problem with this is that any token including the kvp delimiter
(currently '/') gets divided, and is not found correctly during bayes
kvp searching. The quickest solution to this is to replace all "/"
characters with some other character. That has been done, along with a
re-structuring of the bayes matching code to take advantage of c++
features to make the code more concise and readable.

Also modified some test functions to fix leaks and double-frees: the
same kvp value can't be in the kvp tree twice.

Also, when I added code to clean up after the tests, some things started
breaking due to double-delete. Apparently const_cast was hiding some
programming errors. Really? You don't say? When giving a GUID* to KvpValue,
the latter takes ownership of the former.
2017-12-21 07:39:32 -05:00
Geert Janssens 83d14e1c1c Restructure the src directory
It is split into
- /libgnucash (for the non-gui bits)
- /gnucash (for the gui)
- /common (misc source files used by both)
- /bindings (currently only holds python bindings)

This is the first step in restructuring the code. It will need much
more fine tuning later on.
2017-08-10 18:45:00 +02:00