This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: avl-trees vs. hashes


On Wed, 28 Oct 1998, Jay Glascoe wrote:

> On Wed, 28 Oct 1998, Dirk Herrmann wrote:
> 
> > I think the best solution is to _not_ store the hash by default.
<snip>
> > 
> 
> Right now, I'm opposed to rewriting my extension to make
> hash storing optional for two reasons:
> 
<snip>
> 

I don't know, the more I think about it, the more sense it makes to not
store the hash in certain, fairly common cases:

keys are symbols
keys are integers (-2^29 <= key < 2^29, so it's not a "big number")

in these cases, hashing the key is trivial (use the symbols internal
address, a long integer, use the numbers value ((scm_num << 1) << 1))
In a way, the key really is it's own hash value; it would be silly to
store the hash in such cases.

silly me.  I think I will make hash-storing optional (on by default,
though), but don't be surprised if my C code becomes a monument to
non-reusable coding  ;)

	Jay
	jglascoe@jay.giss.nasa.gov