[GNC-dev] Slow user interface in 3.x gnucash (for large files), and potential optimization
John Ralls
jralls at ceridwen.us
Fri Jun 15 13:05:09 EDT 2018
> On Jun 15, 2018, at 9:16 AM, Derek Atkins <warlord at MIT.EDU> wrote:
>
> John Ralls <jralls at ceridwen.us> writes:
>
>> A very good catch indeed. But pre-constructing the string in
>> qofbook.cpp only saves two string constructions per invocation as the
>> vector still has to make its own copies. I guess that its much worse
>> for you because the ancient gcc on Ubuntu 14.04 (gcc4.8) doesn't do
>> small-string optimization.
>
> Is there any reason we cant use std::string& in the vector? Or do we
> think that we might lose references there?
>
In this instance the string is static so it would be safe to use const std::string&, but while there's an is_volatile type trait there's no is_static so we can't insert a static assert to catch cases where the actual std::string is on the stack. That could lead to some ugly bugs.
Besides, using strings is still leaving performance on the table: A string comparison is n times longer than an int comparison where n is the number of consecutive leading characters that are the same in the two strings. I got a huge speedup on loading a few months ago because GncGUID's operator==() was doing a character-wise comparison of the ascii representation instead of comparing the two int64_ts of the actual GUID.
Regards,
John Ralls
More information about the gnucash-devel
mailing list