This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Guile loading speed: What a little function can do...
- To: guile at sourceware dot cygnus dot com
- Subject: Guile loading speed: What a little function can do...
- From: Mikael Djurfeldt <mdj at mdj dot nada dot kth dot se>
- Date: Sun, 04 Jun 2000 03:39:30 +0200
- Reply-to: Mikael Djurfeldt <djurfeldt at nada dot kth dot se>
The major reason for Guile's slow loading speed has always been the
fact that a chain of Scheme level procedures has been evaluated for
every top-level symbol lookup during the first pass through the code.
I've suggested a simple kludge to fix this and have repeated the
argument at many occasions during the years when the discussion has
returned. Personally, I've never been bothered by Guile's slow
loading speed, so I thought I would let someone else do it...
After four years, I conclude that "someone else" is a lazy bastard who
is perfectly willing to spend 100 times the energy *discussing* the
problem than the energy required to write the following function. ;-)
static SCM
module_variable (SCM module, SCM sym)
{
/* 1. Check module obarray */
SCM b = scm_hashq_ref (OBARRAY (module), sym, SCM_UNDEFINED);
if (SCM_VARIABLEP (b))
return b;
{
SCM binder = BINDER (module);
if (SCM_NFALSEP (binder))
/* 2. Custom binder */
{
b = scm_apply (binder,
SCM_LIST3 (module, sym, SCM_BOOL_F),
SCM_EOL);
if (SCM_NFALSEP (b))
return b;
}
}
{
/* 3. Search the use list */
SCM uses = USES (module);
while (SCM_CONSP (uses))
{
b = module_variable (SCM_CAR (uses), sym);
if (SCM_NFALSEP (b))
return b;
uses = SCM_CDR (uses);
}
return SCM_BOOL_F;
}
}