new html-acct-table patch [was Re: html-acct-table patch]

Andrew Sackville-West ajswest at
Wed Oct 31 16:00:14 EDT 2007

On Wed, Oct 31, 2007 at 01:34:57PM -0400, Mike Alexander wrote:

> The main 
> difference is to use a hash table instead of a list to save the account 
> balances.  This cuts another 11% or so off the time for my balance sheet 
> report.

I read up a bit on hash-tables and have some questions/comments. These
are genuine questions, and not criticism of your code, so please help
me learn here...

+      (calculate-balances-helper accts start-date end-date
+                                 (make-hash-table 23))                                 

you have arbitrarily (it appears) set the hash table to 23
slots. Granted, a hash table can grow, and for these purposes it
doesn't matter what size it really is. But since we can easily count
the number of slots needed, why not do that? or if you don't want to
bother counting it, it is a reasonable assumption there will be 1
acct, so why not make it 1? I do understand that it should be a prime
number for some reason I don't understand... but I'm curious.

+                (hash-set! acct-balances (gncAccountGetGUID (car accts))
+                    (get-balance-nosub-mode (car accts) start-date

per, hash-set!
finds the key in table and assigns the value to that slot. So this
implies that the key already exists. What happens if the key doesn't
exist? In this case, it appears that the key gets created and the
value stored. But this is not stated and appears to be a side-effect
of whtat the functionis supposed to do. It seems to me that this behavior may not be
guaranteed and it may be better to use something like 

(hash-create-handle! acct-balances ...) 

since that's what its designed for. It would suck to have guile decide
to change behavior with regards to hash-set! and start just returning
a #f or something instead of creating the new handle. your comments
are appreciated.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : 

More information about the gnucash-devel mailing list