Commit e333157c authored by Noam Postavsky's avatar Noam Postavsky
Browse files

Optimize ucs-normalize.el compilation

* lisp/international/ucs-normalize.el (ucs-normalize-combining-chars-regexp):
(quick-check-list-to-regexp): Use regexp-opt-charset instead of
regexp-opt.
* lisp/international/ucs-normalize.el (quick-check-list): Reuse a single
temp buffer for the whole loop.
parent eed3b46c
...@@ -263,7 +263,7 @@ Note that Hangul are excluded.") ...@@ -263,7 +263,7 @@ Note that Hangul are excluded.")
(defvar ucs-normalize-combining-chars-regexp nil (defvar ucs-normalize-combining-chars-regexp nil
"Regular expression to match sequence of combining characters.") "Regular expression to match sequence of combining characters.")
(setq ucs-normalize-combining-chars-regexp (setq ucs-normalize-combining-chars-regexp
(eval-when-compile (concat (regexp-opt (mapcar 'char-to-string combining-chars)) "+"))) (eval-when-compile (concat (regexp-opt-charset combining-chars) "+")))
(declare-function decomposition-translation-alist "ucs-normalize" (declare-function decomposition-translation-alist "ucs-normalize"
(decomposition-function)) (decomposition-function))
...@@ -396,20 +396,22 @@ If COMPOSITION-PREDICATE is not given, then do nothing." ...@@ -396,20 +396,22 @@ If COMPOSITION-PREDICATE is not given, then do nothing."
It includes Singletons, CompositionExclusions, and Non-Starter It includes Singletons, CompositionExclusions, and Non-Starter
decomposition." decomposition."
(let (entries decomposition composition) (let (entries decomposition composition)
(mapc (with-temp-buffer
(lambda (start-end) (mapc
(cl-do ((i (car start-end) (+ i 1))) ((> i (cdr start-end))) (lambda (start-end)
(setq decomposition (cl-do ((i (car start-end) (+ i 1))) ((> i (cdr start-end)))
(string-to-list (setq decomposition
(with-temp-buffer (string-to-list
(insert i) (progn
(translate-region 1 2 decomposition-translation) (erase-buffer)
(buffer-string)))) (insert i)
(setq composition (translate-region 1 2 decomposition-translation)
(ucs-normalize-block-compose-chars decomposition composition-predicate)) (buffer-string))))
(when (not (equal composition (list i))) (setq composition
(setq entries (cons i entries))))) (ucs-normalize-block-compose-chars decomposition composition-predicate))
check-range) (when (not (equal composition (list i)))
(setq entries (cons i entries)))))
check-range))
;;(remove-duplicates ;;(remove-duplicates
(append entries (append entries
ucs-normalize-composition-exclusions ucs-normalize-composition-exclusions
...@@ -431,7 +433,7 @@ decomposition." ...@@ -431,7 +433,7 @@ decomposition."
(setq hfs-nfc-quick-check-list (quick-check-list 'ucs-normalize-hfs-nfd-table t )) (setq hfs-nfc-quick-check-list (quick-check-list 'ucs-normalize-hfs-nfd-table t ))
(defun quick-check-list-to-regexp (quick-check-list) (defun quick-check-list-to-regexp (quick-check-list)
(regexp-opt (mapcar 'char-to-string (append quick-check-list combining-chars)))) (regexp-opt-charset (append quick-check-list combining-chars)))
(defun quick-check-decomposition-list-to-regexp (quick-check-list) (defun quick-check-decomposition-list-to-regexp (quick-check-list)
(concat (quick-check-list-to-regexp quick-check-list) "\\|[가-힣]")) (concat (quick-check-list-to-regexp quick-check-list) "\\|[가-힣]"))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment