Bill Carlson's performance improvement patch.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@2631 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2000-08-04 16:08:20 +00:00
parent 1326360fea
commit 141bf58dd3
4 changed files with 47 additions and 10 deletions

View File

@ -46,6 +46,7 @@ Per Bojsen <bojsen@worldnet.att.net> several core dump fixes
Terry Boldt <tboldt@attglobal.net> financial calculator and expression parser
Simon Britnell <simon.britnell@peace.com> patch to RPM spec
Christopher B. Browne <cbbrowne@hex.net> for perl and lots of scheme
Bill Carlson <wwc@wwcnet.nu> performance improvements
Graham Chapman <grahamc@zeta.org.au> for the xacc-rpts addon package
George Chen <georgec@sco.com> for MS-Money QIF's & fixes
Albert Chin-A-Young <china@thewrittenword.com> configure.in patch

View File

@ -259,6 +259,10 @@
of changes to English documentation, and lots of guile
code</dd>
<dt><a href="mailto:wwc@wwcnet.nu">Bill Carlson</a></dt>
<dd>performance improvements</dd>
<dt><a href="mailto:grahamc@zeta.org.au">Graham
Chapman</a></dt>

View File

@ -441,29 +441,38 @@ xaccAccountInsertSplit ( Account *acc, Split *split )
/* Find the insertion point */
/* to get realy fancy, could use binary search. */
for(i = 0; i < (acc->numSplits - 1);) {
if(xaccSplitDateOrder(&(oldsplits[i]), &split) > 0) {
break;
} else {
acc->splits[i] = oldsplits[i];
/* but to get just a little fancy, see if it's after the last one */
if ((acc->numSplits > 1)
&& xaccSplitDateOrder(&split, &(oldsplits[acc->numSplits - 2])) > 0) {
i = acc->numSplits - 1;
memcpy (&acc->splits[0], &oldsplits[0],
(acc->numSplits-1) * sizeof (oldsplits[0]));
}
else {
for(i = 0; i < (acc->numSplits - 1);) {
if(xaccSplitDateOrder(&(oldsplits[i]), &split) > 0) {
break;
} else {
acc->splits[i] = oldsplits[i];
}
i++; /* Don't put this in the loop guard! It'll go too far. */
}
i++; /* Don't put this in the loop guard! It'll go too far. */
}
/* Insertion point is now i */
PINFO ("Insertion position is: %d\n", i);
/* Move all the other splits down (this could be done faster with memmove)*/
for( j = acc->numSplits; j > i; j--) {
acc->splits[j] = oldsplits[j - 1];
}
/* Now insert the new split */
acc->splits[i] = split;
/* make sure the array is NULL terminated */
acc->splits[acc->numSplits] = NULL;
_free(oldsplits);
} else {
acc->numSplits ++;
@ -568,6 +577,10 @@ xaccAccountRecomputeBalance( Account * acc )
Split *split, *last_split = NULL;
if( NULL == acc ) return;
/*
* if we are defering, defer!
*/
if (acc->open & ACC_DEFER_REBALANCE) return;
if (0x0 == (ACC_INVALID_BALN & acc->changed)) return;
acc->changed &= ~ACC_INVALID_BALN;

View File

@ -81,6 +81,23 @@ xaccMallocAccountGroup( void )
/********************************************************************\
\********************************************************************/
static void
xaccAccountGroupBeginEdit( AccountGroup *grp, int defer )
{
int i;
if (NULL == grp) return;
for(i = 0; i < grp->numAcc; i++ )
{
xaccAccountBeginEdit(grp->account[i], defer);
xaccAccountGroupBeginEdit (grp->account[i]->children, defer);
}
}
/********************************************************************\
\********************************************************************/
void
xaccFreeAccountGroup( AccountGroup *grp )
{
@ -88,6 +105,8 @@ xaccFreeAccountGroup( AccountGroup *grp )
if (NULL == grp) return;
xaccAccountGroupBeginEdit (grp, 1);
for( i=0; i<grp->numAcc; i++ )
xaccFreeAccount( grp->account[i] );