[PATCH] sort lots and entries on save

Jim Radford radford at blackbean.org
Mon Sep 15 15:54:37 EDT 2008


On Mon, Sep 15, 2008 at 09:14:59PM +0200, Andreas Köhler wrote:
> On Mon, 2008-09-15 at 11:35 -0700, Jim Radford wrote:
> > The following patch sorts the lots and entries before saving them
> > to the gnucash XML file.

> > This is an attempt to make saves more idempotent thereby
> > facilitating the use of a revision control system on the gnucash
> > XML files.

> > With this patch most of the needless and seemingly random churn is
> > gone and I can add and remove a transation and expect there to be
> > no changes to the gnucash file and I can add a transaction and
> > expect that addition to be the only change in the file.

> > I'm curious to see if this patch affects save performance
> > noticeably for anyone.  I don't have any large files to test with.

> Two thoughts that come to my mind:

> (1) qof_object_foreach_sorted() would not belong into
> src/business/business-core but rather lib/libqof/qof.

Of course.  This is just a proof of concept.

> (2) I do not like idea behind it.

Any reasons?

> You should not depend on the fact that the save operation may be in
> any way idempotent.  At least that is my opinion, others may speak
> differently.

I don't depend on it, nor would I expect the developers to be held to
it, but random reordering seems pointless when keeping the order
stable is so easy.  It could even be efficient if new entries were
inserted in order to begin with (at an amortized cost) instead sorted
on save.

-Jim


More information about the gnucash-devel mailing list