This is the mail archive of the guile@sourceware.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: Using SCMs as hash keys


Russell McManus <russell.mcmanus@msdw.com> writes:

> Andrew Chadwick <andrew.chadwick@symbian.com> writes:
> 
> > I know that a SCM is a long with type bits, and I'll be doing a
> > scm_protect_object on each key as it gets added. g_int_hash() and
> > g_int_equal() seem to do the right thing on my system. Are there any
> > issues involved with pulling out these SCMs and exporting them back to
> > the Guile environment in a list?
> 
> Don't use scm_protect_object on a large number of objects; it's slow.
> Protect a single hash table and put the objects in there.

Actually the hash table is a GHashTable from GLib (it must be queried
quickly and regularly from the C side, but never from the Scheme side)
But thanks for the warning; the hash does need adding to and deleting
from fairly frequently too.

Perhaps it would be simpler to scm_protect_object() a vector on the
Scheme side. Would a scm_vector_set_length_x() followed by a
scm_vector_set_x() be any quicker?

-- 
Andrew Chadwick
System Documentation
Symbian Ltd.


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