changeset 48882:d17c0d3e36ba

(ucs-mule-cjk-to-unicode) (ucs-unicode-to-mule-cjk): Revert last change. (utf-subst-table-for-encode): Initially use ucs-mule-cjk-to-unicode. (utf-subst-table-for-decode): Initially use ucs-unicode-to-mule-cjk. (utf-fragment-on-decoding, utf-translate-cjk): Don't modify char-coding-system-table elements destructively. (utf-translate-cjk): Set ucs-mule-cjk-to-unicode, ucs-unicode-to-mule-cjk to new hash tables with realistic parameters.
author Dave Love <fx@gnu.org>
date Tue, 17 Dec 2002 17:58:13 +0000
parents 23fcd656a17e
children 2bce492766d6
files lisp/international/utf-8.el
diffstat 1 files changed, 20 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/international/utf-8.el	Tue Dec 17 11:57:18 2002 +0000
+++ b/lisp/international/utf-8.el	Tue Dec 17 17:58:13 2002 +0000
@@ -95,25 +95,23 @@
 (define-translation-table 'utf-translation-table-for-decode)
 
 
-(defvar ucs-mule-cjk-to-unicode (make-hash-table :test 'eq :size 43000
-						 :rehash-size 1000)
+(defvar ucs-mule-cjk-to-unicode (make-hash-table :test 'eq)
   "Hash table mapping Emacs CJK character sets to Unicode code points.
 
 If `utf-translate-cjk' is non-nil, this table populates the
 translation-hash-table named `utf-subst-table-for-encode'.")
 
-(define-translation-hash-table 'utf-subst-table-for-encode 
-  (make-hash-table :test 'eq :size 43000 :rehash-size 1000))
+(define-translation-hash-table 'utf-subst-table-for-encode
+  ucs-mule-cjk-to-unicode)
 
-(defvar ucs-unicode-to-mule-cjk (make-hash-table :test 'eq :size 43000
-						 :rehash-size 1000)
+(defvar ucs-unicode-to-mule-cjk (make-hash-table :test 'eq)
   "Hash table mapping Unicode code points to Emacs CJK character sets.
 
 If `utf-translate-cjk' is non-nil, this table populates the
 translation-hash-table named `utf-subst-table-for-decode'.")
 
 (define-translation-hash-table 'utf-subst-table-for-decode
-  (make-hash-table :test 'eq :size 21500 :rehash-size 200))
+  ucs-unicode-to-mule-cjk)
 
 (mapc
  (lambda (pair)
@@ -194,9 +192,9 @@
 	      (lambda (key val)
 		(if (and (>= key 128) val)
 		    (aset char-coding-system-table key
-			  (delq 'mule-utf-8
-				(delq 'mule-utf-16-le
-				      (delq 'mule-utf-16-be
+			  (remq 'mule-utf-8
+				(remq 'mule-utf-16-le
+				      (remq 'mule-utf-16-be
 					    (aref char-coding-system-table
 						  key)))))))
 	      utf-defragmentation-table)))
@@ -222,7 +220,16 @@
 default.  Also, installing them may be rather slow."
   :set (lambda (s v)
 	 (if v
+	     ;; Fixme: Allow the use of the CJK charsets to be
+	     ;; customized by reordering and possible omission.
 	     (progn
+	       ;; Redefine them with realistic initial sizes and a
+	       ;; smallish rehash size to avoid wasting significant
+	       ;; space after they're built.
+	       (setq ucs-mule-cjk-to-unicode
+		     (make-hash-table :test 'eq :size 43000 :rehash-size 1000)
+		     ucs-unicode-to-mule-cjk
+		     (make-hash-table :test 'eq :size 43000 :rehash-size 1000))
 	       ;; Load the files explicitly, to avoid having to keep
 	       ;; around the large tables they contain (as well as the
 	       ;; ones which get built).
@@ -262,9 +269,9 @@
 	    (lambda (k v)
 	      (if (gethash k ucs-mule-cjk-to-unicode)
 		  (aset char-coding-system-table k
-			(delq 'mule-utf-8
-			      (delq 'mule-utf-16-le
-				    (delq 'mule-utf-16-be v))))))
+			(remq 'mule-utf-8
+			      (remq 'mule-utf-16-le
+				    (remq 'mule-utf-16-be v))))))
 	    char-coding-system-table)
 	   (define-translation-hash-table 'utf-subst-table-for-decode
 	     (make-hash-table :test 'eq))