diff options
| author | Noam Postavsky | 2016-07-15 22:10:33 -0400 |
|---|---|---|
| committer | Noam Postavsky | 2016-07-16 13:01:04 -0400 |
| commit | e333157cba3b4ffd7c25f8210a6aa5a21ae10de7 (patch) | |
| tree | 79efedb617ab550d12981778eccc7258fdea0ad4 | |
| parent | eed3b46ca184b5bca1dc341e3204f1539b831104 (diff) | |
| download | emacs-e333157cba3b4ffd7c25f8210a6aa5a21ae10de7.tar.gz emacs-e333157cba3b4ffd7c25f8210a6aa5a21ae10de7.zip | |
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.
| -rw-r--r-- | lisp/international/ucs-normalize.el | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/lisp/international/ucs-normalize.el b/lisp/international/ucs-normalize.el index 4b364ee4ebb..ac2a0d9e778 100644 --- a/lisp/international/ucs-normalize.el +++ b/lisp/international/ucs-normalize.el | |||
| @@ -263,7 +263,7 @@ Note that Hangul are excluded.") | |||
| 263 | (defvar ucs-normalize-combining-chars-regexp nil | 263 | (defvar ucs-normalize-combining-chars-regexp nil |
| 264 | "Regular expression to match sequence of combining characters.") | 264 | "Regular expression to match sequence of combining characters.") |
| 265 | (setq ucs-normalize-combining-chars-regexp | 265 | (setq ucs-normalize-combining-chars-regexp |
| 266 | (eval-when-compile (concat (regexp-opt (mapcar 'char-to-string combining-chars)) "+"))) | 266 | (eval-when-compile (concat (regexp-opt-charset combining-chars) "+"))) |
| 267 | 267 | ||
| 268 | (declare-function decomposition-translation-alist "ucs-normalize" | 268 | (declare-function decomposition-translation-alist "ucs-normalize" |
| 269 | (decomposition-function)) | 269 | (decomposition-function)) |
| @@ -396,20 +396,22 @@ If COMPOSITION-PREDICATE is not given, then do nothing." | |||
| 396 | It includes Singletons, CompositionExclusions, and Non-Starter | 396 | It includes Singletons, CompositionExclusions, and Non-Starter |
| 397 | decomposition." | 397 | decomposition." |
| 398 | (let (entries decomposition composition) | 398 | (let (entries decomposition composition) |
| 399 | (mapc | 399 | (with-temp-buffer |
| 400 | (lambda (start-end) | 400 | (mapc |
| 401 | (cl-do ((i (car start-end) (+ i 1))) ((> i (cdr start-end))) | 401 | (lambda (start-end) |
| 402 | (setq decomposition | 402 | (cl-do ((i (car start-end) (+ i 1))) ((> i (cdr start-end))) |
| 403 | (string-to-list | 403 | (setq decomposition |
| 404 | (with-temp-buffer | 404 | (string-to-list |
| 405 | (insert i) | 405 | (progn |
| 406 | (translate-region 1 2 decomposition-translation) | 406 | (erase-buffer) |
| 407 | (buffer-string)))) | 407 | (insert i) |
| 408 | (setq composition | 408 | (translate-region 1 2 decomposition-translation) |
| 409 | (ucs-normalize-block-compose-chars decomposition composition-predicate)) | 409 | (buffer-string)))) |
| 410 | (when (not (equal composition (list i))) | 410 | (setq composition |
| 411 | (setq entries (cons i entries))))) | 411 | (ucs-normalize-block-compose-chars decomposition composition-predicate)) |
| 412 | check-range) | 412 | (when (not (equal composition (list i))) |
| 413 | (setq entries (cons i entries))))) | ||
| 414 | check-range)) | ||
| 413 | ;;(remove-duplicates | 415 | ;;(remove-duplicates |
| 414 | (append entries | 416 | (append entries |
| 415 | ucs-normalize-composition-exclusions | 417 | ucs-normalize-composition-exclusions |
| @@ -431,7 +433,7 @@ decomposition." | |||
| 431 | (setq hfs-nfc-quick-check-list (quick-check-list 'ucs-normalize-hfs-nfd-table t )) | 433 | (setq hfs-nfc-quick-check-list (quick-check-list 'ucs-normalize-hfs-nfd-table t )) |
| 432 | 434 | ||
| 433 | (defun quick-check-list-to-regexp (quick-check-list) | 435 | (defun quick-check-list-to-regexp (quick-check-list) |
| 434 | (regexp-opt (mapcar 'char-to-string (append quick-check-list combining-chars)))) | 436 | (regexp-opt-charset (append quick-check-list combining-chars))) |
| 435 | 437 | ||
| 436 | (defun quick-check-decomposition-list-to-regexp (quick-check-list) | 438 | (defun quick-check-decomposition-list-to-regexp (quick-check-list) |
| 437 | (concat (quick-check-list-to-regexp quick-check-list) "\\|[가-힣]")) | 439 | (concat (quick-check-list-to-regexp quick-check-list) "\\|[가-힣]")) |