comparison lisp/international/mule.el @ 48891:49c591ef85fb

(optimize-char-coding-system-table): New. (register-char-codings): Use it.
author Dave Love <fx@gnu.org>
date Wed, 18 Dec 2002 23:21:50 +0000
parents 669a7bd630a8
children 4ecab4bfe0cd
comparison
equal deleted inserted replaced
48890:f4d223f5f6ef 48891:49c591ef85fb
590 (dotimes (i chars) 590 (dotimes (i chars)
591 (funcall func 591 (funcall func
592 (make-char charset (+ i start) start) 592 (make-char charset (+ i start) start)
593 (make-char charset (+ i start) (+ start chars -1))))))) 593 (make-char charset (+ i start) (+ start chars -1)))))))
594 594
595 (defun optimize-char-coding-system-table ()
596 "Optimize `char-coding-system-table'.
597 Elements which compare `equal' are modified to share the same list."
598 (let (cache)
599 (map-char-table
600 (lambda (k v)
601 ;; This doesn't worry about elements which are permutations of
602 ;; each other. As it is, with utf-translate-cjk on and
603 ;; code-pages loaded, the table has ~50k elements, which are
604 ;; reduced to ~1k. (`optimize-char-table' might win if
605 ;; permutations were eliminated, but that's probably a small
606 ;; effect and not easy to test.)
607 (let ((existing (car (member v cache))))
608 (if existing
609 (aset char-coding-system-table k existing)
610 (push v cache))))
611 char-coding-system-table))
612 (optimize-char-table char-coding-system-table))
613
595 (defun register-char-codings (coding-system safe-chars) 614 (defun register-char-codings (coding-system safe-chars)
596 "Add entries for CODING-SYSTEM to `char-coding-system-table'. 615 "Add entries for CODING-SYSTEM to `char-coding-system-table'.
597 If SAFE-CHARS is a char-table, its non-nil entries specify characters 616 If SAFE-CHARS is a char-table, its non-nil entries specify characters
598 which CODING-SYSTEM encodes safely. If SAFE-CHARS is t, register 617 which CODING-SYSTEM encodes safely. If SAFE-CHARS is t, register
599 CODING-SYSTEM as a general one which can encode all characters." 618 CODING-SYSTEM as a general one which can encode all characters."
642 (cons coding-system codings)) 661 (cons coding-system codings))
643 (unless (or (memq charset partials) 662 (unless (or (memq charset partials)
644 (generic-char-p key)) 663 (generic-char-p key))
645 (push charset partials))))))) 664 (push charset partials)))))))
646 safe-chars) 665 safe-chars)
666 (optimize-char-coding-system-table)
647 (set-char-table-extra-slot char-coding-system-table 1 partials)))) 667 (set-char-table-extra-slot char-coding-system-table 1 partials))))
648
649 668
650 (defun make-subsidiary-coding-system (coding-system) 669 (defun make-subsidiary-coding-system (coding-system)
651 "Make subsidiary coding systems (eol-type variants) of CODING-SYSTEM." 670 "Make subsidiary coding systems (eol-type variants) of CODING-SYSTEM."
652 (let ((coding-spec (coding-system-spec coding-system)) 671 (let ((coding-spec (coding-system-spec coding-system))
653 (subsidiaries (vector (intern (format "%s-unix" coding-system)) 672 (subsidiaries (vector (intern (format "%s-unix" coding-system))