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: Scm_sloppy_assq mostly fixed, still real slow



protect() and unprotect() should be used only once per
module/application. 

If you want to protect objects temporarily, it's better
to create your own protect data structures:


#define M_P0_list 0
#define M_P1_list 1
...

static SCM my_protect_vec;
void init()
{
  /* create supporting data structures */
  protect_vec = scm_make_vector(SCM_MAKINUM(M_max), SCM_UNDEFINED);
  scm_permanent_object(my_protect_vec);
}

void add_protected_element(SCM el)
{
  SCM old_list = scm_vector_ref(protect_vec, M_list)
  scm_vector_set_x(protect_vec, M_P0_LIST, scm_cons(el, old_list));
}


> * Is it an error to unprotect an object too many times? I think that
> happens occasionally.

No.


Jost

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