gnucash maint: Multiple changes pushed
John Ralls
jralls at code.gnucash.org
Fri Jan 4 18:57:44 EST 2019
Updated via https://github.com/Gnucash/gnucash/commit/137c920d (commit)
via https://github.com/Gnucash/gnucash/commit/a65dd6cc (commit)
via https://github.com/Gnucash/gnucash/commit/2b692786 (commit)
via https://github.com/Gnucash/gnucash/commit/0e37e059 (commit)
from https://github.com/Gnucash/gnucash/commit/7a13398e (commit)
commit 137c920d060d197d6a845b1a3cf5a88d8987d3f6
Merge: a65dd6c 2b69278
Author: John Ralls <jralls at ceridwen.us>
Date: Fri Jan 4 15:50:39 2019 -0800
Merge Chris Carson's 'dateFormat' into maint.
commit a65dd6cc253ec3f4da21074cfe8b8443b4d2d64f
Merge: 7a13398 0e37e05
Author: John Ralls <jralls at ceridwen.us>
Date: Fri Jan 4 15:49:42 2019 -0800
Merge Chris Carson's 'refactor-Scrub-c' into maint.
commit 2b69278650f55b8ceed4eef9f4268a60138045a0
Author: Christopher D. Carson <chriscarson60187 at gmail.com>
Date: Tue Jan 1 06:20:23 2019 -0600
Re-coded for cached locale.
Testing notes: Based on the averages of 3 runs, the net
user CPU to save the XML file I use is:
10.2 seconds without this change
7.6 seconds with this change
In my environment the first call to the format routine
in question, the call that sets the cache value, is at
the end of the XML load.
diff --git a/libgnucash/engine/gnc-datetime.cpp b/libgnucash/engine/gnc-datetime.cpp
index f5d9916..238be2d 100644
--- a/libgnucash/engine/gnc-datetime.cpp
+++ b/libgnucash/engine/gnc-datetime.cpp
@@ -425,11 +425,21 @@ std::string
GncDateTimeImpl::format(const char* format) const
{
using Facet = boost::local_time::local_time_facet;
+ static std::locale cachedLocale;
+ static bool cachedLocaleAvailable = false;
std::stringstream ss;
+
+ if(!cachedLocaleAvailable)
+ {
+ cachedLocale = std::locale("");
+ cachedLocaleAvailable = true;
+ }
+
//The stream destructor frees the facet, so it must be heap-allocated.
auto output_facet(new Facet(normalize_format(format).c_str()));
// FIXME Rather than imbueing a locale below we probably should set std::locale::global appropriately somewhere.
- ss.imbue(std::locale(std::locale(""), output_facet));
+ // At that point the use of cachedLocale mechanism should be removed.
+ ss.imbue(std::locale(cachedLocale, output_facet));
ss << m_time;
return ss.str();
}
commit 0e37e059d504d9e2ab2ececd0979ec87a93fea1e
Author: Christopher D. Carson <chriscarson60187 at gmail.com>
Date: Sat Dec 29 06:45:47 2018 -0600
Fix XML load CPU hotspot: Scrub.c xaccTransScrubPostedDate
The refactoring provides roughly 10% reduction in user CPU
use for XML file load by moving an expensive function
to within an if-clause where the result is used. The diff looks
like a full re-write but only the if statements, indenting,
and commentary changed.
diff --git a/libgnucash/engine/Scrub.c b/libgnucash/engine/Scrub.c
index d6ff107..4b32150 100644
--- a/libgnucash/engine/Scrub.c
+++ b/libgnucash/engine/Scrub.c
@@ -1395,13 +1395,15 @@ void
xaccTransScrubPostedDate (Transaction *trans)
{
time64 orig = xaccTransGetDate(trans);
- GDate date = xaccTransGetDatePostedGDate(trans);
- time64 time = gdate_to_time64(date);
- /* xaccTransGetDatePostedGDate will return a valid time */
- if (orig == INT64_MAX && orig != time)
+ if(orig == INT64_MAX)
{
- /* xaccTransSetDatePostedSecs handles committing the change. */
- xaccTransSetDatePostedSecs(trans, time);
+ GDate date = xaccTransGetDatePostedGDate(trans);
+ time64 time = gdate_to_time64(date);
+ if(time != INT64_MAX)
+ {
+ // xaccTransSetDatePostedSecs handles committing the change.
+ xaccTransSetDatePostedSecs(trans, time);
+ }
}
}
Summary of changes:
libgnucash/engine/Scrub.c | 14 ++++++++------
libgnucash/engine/gnc-datetime.cpp | 12 +++++++++++-
2 files changed, 19 insertions(+), 7 deletions(-)
More information about the gnucash-changes
mailing list