Ar an cúigiú lá déag de mí na Samhain, scríobh stephen(a)xemacs.org:
Wouldn't it be faster to code this in terms of Bytebpos
(whichever
groks the gap):
Sure; which one groks the gap, though? :-)
Ibyte *pos, *stop; /* initialize these */
while (pos < stop)
{
if (0 == charsets[*pos - MIN_LEADING_BYTE])
{
charsets[*pos - MIN_LEADING_BYTE];
res = Fcons (XCHARSET_NAME(charset_by_leading_byte(*pos)), res);
}
INC_IBYTE_PTR (pos);
}
(I originally thought it would be clearer but actually looking at it
it seems to be a tossup.) I think it's worth optimizing because (eg)
it would some of the code in latin-unity clearer and easier to
generalize if we could use this (it was way too slow when it was in
Lisp). (Of course your code is plenty fast, but if there's an easy
optimization it's probably worth it.)
Faster still in the normal case would be a combination of the
BUFFER_TEXT_LOOP macro in buffer.h and skip_ascii() in text.c.
It also occurs to me that we should have a map-text iterator to
replace idioms like
(save-excursion
(while condition
(do-something (char-after (point)))
(forward-char 1)))
Do you think that's overkill?
Hmm, a little. Tangentally I was considering implementing
with-string-as-buffer-text in C for the sake of charsets-in-string and
decode-coding-string , but almost nothing else appears to use them, so it
may not be worth the maintenance.
--
Santa Maradona, priez pour moi!
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-patches