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.
This commit is contained in:
Christopher D. Carson 2018-12-29 06:45:47 -06:00
parent 0621abf3b1
commit 0e37e059d5

View File

@ -1395,14 +1395,16 @@ void
xaccTransScrubPostedDate (Transaction *trans)
{
time64 orig = xaccTransGetDate(trans);
if(orig == INT64_MAX)
{
GDate date = xaccTransGetDatePostedGDate(trans);
time64 time = gdate_to_time64(date);
/* xaccTransGetDatePostedGDate will return a valid time */
if (orig == INT64_MAX && orig != time)
if(time != INT64_MAX)
{
/* xaccTransSetDatePostedSecs handles committing the change. */
// xaccTransSetDatePostedSecs handles committing the change.
xaccTransSetDatePostedSecs(trans, time);
}
}
}
/* ==================== END OF FILE ==================== */