string-delete looks like it throws off a fair bit of garbage, a cons cell for every character in the output string.
I'm thinking of the following for the "char" and "charset" deleting cases. Count what will be kept then copy to a destination string. I'm not quite sure about the scm_i_string_chars though. The idea is to call that again after anything that might gc, is it? if (SCM_CHARP (char_pred)) { char chr, *dst; size_t count; chr = SCM_CHAR (char_pred); /* count how many chars to keep */ count = 0; for (idx = cstart; idx < cend; idx++) if (cstr[idx] != chr) count++; /* new string for them (and cstr again in case gc moves it) */ newstr = scm_i_make_string (count, &dst); cstr = scm_i_string_chars (s); /* decrement "count" in this loop as well as using idx, so that if another thread is simultaneously changing the input str we won't go past the end of newstr */ for (idx = cstart; idx < cend && count != 0; idx++, count--) { if (cstr[idx] != chr) *dst++ = cstr[idx]; } result = newstr; } For the "procedure" case, I'm thinking of mallocing a block to keep the characters the procedure says to keep. That block would start out as the size of the input, then be realloced down when the true size is known. _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://lists.gnu.org/mailman/listinfo/guile-devel