Mercurial > hg > xemacs-beta
diff lisp/mule/mule-charset.el @ 3681:3131094eed8c
[xemacs-hg @ 2006-11-15 21:39:51 by aidan]
Move charsets-in-region to C.
author | aidan |
---|---|
date | Wed, 15 Nov 2006 21:40:02 +0000 |
parents | 98af8a976fc3 |
children | a0d288cfcfb5 |
line wrap: on
line diff
--- a/lisp/mule/mule-charset.el Wed Nov 15 21:12:17 2006 +0000 +++ b/lisp/mule/mule-charset.el Wed Nov 15 21:40:02 2006 +0000 @@ -38,42 +38,16 @@ ;;;; Classifying text according to charsets -;; the old version was broken in a couple of ways -;; this is one of several versions, I tried a hash as well as the -;; `prev-charset' cache used in the old version, but this was definitely -;; faster than the hash version and marginally faster than the prev-charset -;; version -;; #### this really needs to be moved into C -(defun charsets-in-region (start end &optional buffer) - "Return a list of the charsets in the region between START and END. -BUFFER defaults to the current buffer if omitted." - (let (list) - (save-excursion - (if buffer - (set-buffer buffer)) - (save-restriction - (narrow-to-region start end) - (goto-char (point-min)) - (while (not (eobp)) - ;; the first test will usually succeed on testing the - ;; car of the list; don't waste time let-binding. - (or (memq (char-charset (char-after (point))) list) - (setq list (cons (char-charset (char-after (point))) list))) - (forward-char)))) - list)) - (defun charsets-in-string (string) "Return a list of the charsets in STRING." - (let (list) - (mapc (lambda (ch) - ;; the first test will usually succeed on testing the - ;; car of the list; don't waste time let-binding. - (or (memq (char-charset ch) list) - (setq list (cons (char-charset ch) list)))) - string) - list)) + (let (res) + (with-string-as-buffer-contents string + ;; charsets-in-region now in C. + (setq res (charsets-in-region (point-min) (point-max)))) + res)) (defalias 'find-charset-string 'charsets-in-string) + (defalias 'find-charset-region 'charsets-in-region)