[Gnucash-changes] r13864 - gnucash/trunk/src/gnome - Remove some unnecessary BeginEdit/CommitEdit calls.

Derek Atkins warlord at MIT.EDU
Thu May 4 09:13:11 EDT 2006


Chris Shoemaker <c.shoemaker at cox.net> writes:

>> > Modified: gnucash/trunk/src/gnome/reconcile-list.c
>> [snip]
>> > -  trans = xaccSplitGetParent(split);
>> > -  xaccTransBeginEdit(trans);
>> >    xaccSplitSetReconcile (split, YREC);
>> >    xaccSplitSetDateReconciledSecs (split, *date);
>> > -  xaccTransCommitEdit(trans);
>> 
>> Don't you want to transactionalize these changes into a single commit?
>
> I don't see much reason to do so.  There aren't any uses or
> documentation that would require these changes to be atomic.  If we
> want to ensure such a requirement, I'd prefer to either 

Efficiency..

> a) add a check to the scrubbing code or; 
>
> (much preferred) b) just offer an API that guarantees data
> consistency, like: xaccSplitSetReconciled(split, *date) that
> automatically used YREC.

It's not a question of requiring atomicity.  It's a question of
efficiency.  Blocking multiple setters into a single 'atomicity
transaction' using begin/commit is much more efficient than calling
each setter individually and using the setter auto-commit
functionality.  Keep in mind that a BeginEdit(), which is done insider
each of the setters, has to perform a copy-for-rollback which can be
expensive, and in a sql environment has to go modify the database for
each one.  Blocking them together saves you the extra malloc/copy/free
operation and only pushes back to SQL once.

>> [snip]
>> > -    trans = xaccSplitGetParent(split);
>> > -    xaccTransBeginEdit(trans);
>> >      xaccSplitSetReconcile (split, recn);
>> > -    xaccTransCommitEdit(trans);
>> 
>> And don't we need to commit this transaction when we're done?
>
> Yes, that happens internally to xaccSplitSetReconcile().

Really?  Hmm.  I wouldn't have thought that, but I guess it makes
some amount of sense.

> -chris

-derek

-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord at MIT.EDU                        PGP key available


More information about the gnucash-devel mailing list