APPROVE
But of course I can't leave well enough alone: a few suggestions and
comments.
Aidan Kehoe writes:
+DEFUN ("charsets-in-region", Fcharsets_in_region, 2, 3, 0,
/*
+Return a list of the charsets in the region between START and END.
+BUFFER defaults to the current buffer if omitted.
I wonder if this couldn't be written for generic text (string or
buffer)? Probably doesn't matter, I don't suppose
"charsets-in-string" is called very often.
+ while (pos < stop)
+ {
+ lb = ichar_leading_byte(BUF_FETCH_CHAR (buf, pos));
+ if (0 == charsets[lb - MIN_LEADING_BYTE])
+ {
+ charsets[lb - MIN_LEADING_BYTE] = 1;
+ res = Fcons (XCHARSET_NAME(charset_by_leading_byte(lb)), res);
+ }
+ ++pos;
+ }
(BTW, I don't know why I didn't see it before, I actually did check
for tabs, but in the above patch snippet because of the tabs all of
the {} and *all* of the controlled statements line up (the statements
2 spaces indented). Sorry, as I say I *thought* I checked for that,
but clearly it was my bad.)
Wouldn't it be faster to code this in terms of Bytebpos (whichever
groks the gap):
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.)
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?
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-patches