This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: [knotwell@f5.com] Re: [PATCH] Re: startup speed (or lack thereof)
- To: knotwell at f5 dot com, Jim Blandy <jimb at red-bean dot com>
- Subject: Re: [knotwell@f5.com] Re: [PATCH] Re: startup speed (or lack thereof)
- From: Dirk Herrmann <dirk at ida dot ing dot tu-bs dot de>
- Date: Tue, 21 Mar 2000 15:04:41 +0100 (MET)
- cc: Guile Mailing List <guile at sourceware dot cygnus dot com>
On 20 Mar 2000, Jim Blandy wrote:
> From: knotwell@f5.com
[...]
> I spent some time in symbols.c (specifically,scm_intern_obarray_soft). I
> made some small changes that make the code a bit easier to understand
> while providing a slight optimization.
>
> scm_hash = scm_strhash (tmp, i, SCM_LENGTH(obarray));
>
> retry_new_obarray:
> for (lsym = SCM_VELTS (obarray)[scm_hash]; SCM_NIMP (lsym); lsym = SCM_CDR (lsym))
> {
> ! SCM a = SCM_CAAR(lsym);
> ! if (SCM_LENGTH(a) != len)
> goto trynext;
> !
> ! tmp = SCM_UCHARS(a);
> ! for(i=len;i--;)
> if (((unsigned char *) name)[i] != tmp[i])
> ! goto trynext;
> !
> ! a = SCM_CAR(lsym);
> ! SCM_REALLOW_INTS;
> ! return a;
> !
> ! trynext:;
> }
>
> if (obarray == scm_symhash)
What about the following solution, which even does avoid using gotos and
relies on memcmp to perform the character field comparison? (The use of
memcmp might cause a performance degradation due to function calling
overhead. For longer symbols, however, memcmp may gain due to a more
efficient implementation. Since it is a standard library call, it might
even get inlined by the compiler automatically. Thus, there are just too
many possibilities for me to tell whether it is a good idea to use it
here. OTOH it will only be called when it is already known that two
symbols of the same length are to be compared.)
for (lsym = SCM_VELTS (obarray)[scm_hash]; SCM_NNULLP (lsym); lsym = SCM_CDR (lsym))
{
SCM symbol_value_pair = SCM_CAR (lsym);
SCM symbol = SCM_CAR (symbol_value_pair);
if (SCM_LENGTH (symbol) == len) {
unsigned char *symbol_chars = SCM_UCHARS (symbol);
if (memcmp (name, symbol_chars, len) == 0) {
SCM_REALLOW_INTS;
return symbol_value_pair;
}
}
}
If nobody objects, I will apply this patch.
Best regards
Dirk Herrmann