Skip to content

Commit

Permalink
[business-core] string-hash doesn't not guarantee unique hash
Browse files Browse the repository at this point in the history
subtle bug here-- used string-hash to convert guid-string to a number
which is faster to use as hash key. but string-hash does not guarantee
that there are no hash collisions. it is best to use guid string
instead which is guaranteed to uniquely define a split.
  • Loading branch information
christopherlam committed Jun 17, 2020
1 parent 6071202 commit 0b38615
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bindings/guile/business-core.scm
Expand Up @@ -129,7 +129,7 @@
((not split)
(hash-for-each (lambda (k v) (gncOwnerFree v)) ht)
(hash-clear! ht))
((hashv-ref ht (string-hash (gncSplitGetGUID split))) => identity)
((hash-ref ht (gncSplitGetGUID split)) => identity)
(else
(let ((lot (xaccSplitGetLot split))
(owner (gncOwnerNew)))
Expand All @@ -138,5 +138,5 @@
(gncInvoiceGetOwner
(gncInvoiceGetInvoiceFromLot lot)))
owner))
(hashv-set! ht (string-hash (gncSplitGetGUID split)) owner)
(hash-set! ht (gncSplitGetGUID split) owner)
owner))))))

1 comment on commit 0b38615

@christopherlam
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lol @jralls I finally see the unintentional and incorrect double negative in this commit message.

Should be "[business-core] string-hash does not guarantee unique hash" of course.

Please sign in to comment.