[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#24603: [PATCH 3/3] Don’t generate ‘X maps to X’ entries in case tabl

From: Michal Nazarewicz
Subject: bug#24603: [PATCH 3/3] Don’t generate ‘X maps to X’ entries in case tables
Date: Tue, 18 Oct 2016 00:03:45 +0200

If character maps to itself when lower or upper casing, do not put
that information in the down or up case tables.  Such entries only
take up space without providing any additional information.  This
shrinks down and up case tables by around 500 entries each.

* lisp/international/characters.el: Don’t set case identity mappings.
 lisp/international/characters.el | 14 ++------------
 test/src/casefiddle-tests.el     |  2 +-
 2 files changed, 3 insertions(+), 13 deletions(-)

diff --git a/lisp/international/characters.el b/lisp/international/characters.el
index 8dd9c73..d992d08 100644
--- a/lisp/international/characters.el
+++ b/lisp/international/characters.el
@@ -715,20 +715,10 @@ ?L
         (down tbl)
         (up (case-table-get-table tbl 'up)))
-    ;; This works on an assumption that if toUpper(x) != x then toLower(x) ==
-    ;; x (and the opposite for toLower/toUpper).  This doesn’t hold for title
-    ;; case characters but those incorrect mappings will be overwritten later.
     (funcall map-unicode-property 'uppercase
-             (lambda (lc uc) (aset down lc lc) (aset up uc uc)))
+             (lambda (lc uc) (aset up lc uc)))
     (funcall map-unicode-property 'lowercase
-             (lambda (uc lc) (aset down lc lc) (aset up uc uc)))
-    ;; Now deal with the actual mapping.  This will correctly assign casing for
-    ;; title-case characters.
-    (funcall map-unicode-property 'uppercase
-             (lambda (lc uc) (aset up lc uc) (aset up uc uc)))
-    (funcall map-unicode-property 'lowercase
-             (lambda (uc lc) (aset down uc lc) (aset down lc lc))))
+             (lambda (uc lc) (aset down uc lc))))
   ;; Clear out the extra slots so that they will be recomputed from the main
   ;; (downcase) table and upcase table.  Since we’re side-stepping the usual
diff --git a/test/src/casefiddle-tests.el b/test/src/casefiddle-tests.el
index 4142aa0..bfc58f5 100644
--- a/test/src/casefiddle-tests.el
+++ b/test/src/casefiddle-tests.el
@@ -91,7 +91,7 @@ casefiddle-tests--characters
              (tabs (list up down)))
          (while props
            (let ((got (aref (car tabs) ch)))
-             (unless (equal (car expected) got)
+             (unless (equal (car expected) (or got ch))
                (push (format "\n%c %s; expected: %s but got: %s"
                              ch (car props) (car expected) got)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]