all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: npostavs@users.sourceforge.net
To: Eli Zaretskii <eliz@gnu.org>
Cc: larsi@gnus.org, 23967@debbugs.gnu.org
Subject: bug#23967: 25.1.50; Slow compilation of ns-win.el
Date: Fri, 15 Jul 2016 22:46:12 -0400	[thread overview]
Message-ID: <87mvlie1vv.fsf@users.sourceforge.net> (raw)
In-Reply-To: <83k2gn74dq.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 15 Jul 2016 10:21:53 +0300")

[-- Attachment #1: Type: text/plain, Size: 1076 bytes --]

Eli Zaretskii <eliz@gnu.org> writes:

>> I stared writing a new one, and it's failing with the original
>> ucs-normalize.el (or I'm misunderstanding the requirements).
>
> If the failures are identical to the original ucs-normalize, let's for
> now just mark them as known failures, and look into them later.  I
> don't want to delay this important change that speeds up the bootstrap
> due to problems unrelated to the change.
>> 
>> Lines 15131 to 15139 and 16149 to 16289 are failing.

I finished writing the tests.  It does pass with
http://www.unicode.org/Public/5.2.0/ucd/NormalizationTest.txt as was
claimed in the ucs-normalize.el file (except that some of the rule 2
tests fail with that version, but that's only because version 5.2.0 has
less code points listed in Part 1).

Here are the patches, first adds the test (I elided the content of
NormalizationTest.txt to save space), second is the optimization (same
as before, except I dropped the change from mapc to dolist, because some
benchmark-runs showed me that mapc is significantly faster when not
compiled).


[-- Attachment #2: patch 1, elided content --]
[-- Type: application/octet-stream, Size: 3683 bytes --]

[-- Attachment #3: patch 2 --]
[-- Type: text/x-diff, Size: 3467 bytes --]

From 821aa63d1efd763d42cf0ae8249727aa7cb692fc Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Fri, 15 Jul 2016 22:10:33 -0400
Subject: [PATCH v1 2/2] 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.
---
 lisp/international/ucs-normalize.el | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/lisp/international/ucs-normalize.el b/lisp/international/ucs-normalize.el
index 4b364ee..ac2a0d9 100644
--- a/lisp/international/ucs-normalize.el
+++ b/lisp/international/ucs-normalize.el
@@ -263,7 +263,7 @@ ucs-normalize-combining-chars
 (defvar ucs-normalize-combining-chars-regexp nil
   "Regular expression to match sequence of combining characters.")
   (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"
                   (decomposition-function))
@@ -396,20 +396,22 @@ ucs-normalize-block-compose-chars
 It includes Singletons, CompositionExclusions, and Non-Starter
 decomposition."
     (let (entries decomposition composition)
-      (mapc
-       (lambda (start-end)
-         (cl-do ((i (car start-end) (+ i 1))) ((> i (cdr start-end)))
-           (setq decomposition
-                 (string-to-list
-                  (with-temp-buffer
-                    (insert i)
-                    (translate-region 1 2 decomposition-translation)
-                    (buffer-string))))
-           (setq composition
-                 (ucs-normalize-block-compose-chars decomposition composition-predicate))
-           (when (not (equal composition (list i)))
-             (setq entries (cons i entries)))))
-       check-range)
+      (with-temp-buffer
+        (mapc
+         (lambda (start-end)
+           (cl-do ((i (car start-end) (+ i 1))) ((> i (cdr start-end)))
+             (setq decomposition
+                   (string-to-list
+                    (progn
+                      (erase-buffer)
+                      (insert i)
+                      (translate-region 1 2 decomposition-translation)
+                      (buffer-string))))
+             (setq composition
+                   (ucs-normalize-block-compose-chars decomposition composition-predicate))
+             (when (not (equal composition (list i)))
+               (setq entries (cons i entries)))))
+         check-range))
       ;;(remove-duplicates
        (append entries
                ucs-normalize-composition-exclusions
@@ -431,7 +433,7 @@ ucs-normalize-block-compose-chars
     (setq hfs-nfc-quick-check-list (quick-check-list 'ucs-normalize-hfs-nfd-table t ))
 
   (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)
     (concat (quick-check-list-to-regexp quick-check-list) "\\|[가-힣]"))
-- 
2.8.0


  reply	other threads:[~2016-07-16  2:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-13 12:19 bug#23967: 25.1.50; Slow compilation of ns-win.el Lars Ingebrigtsen
2016-07-13 14:55 ` Eli Zaretskii
2016-07-13 21:15   ` Noam Postavsky
2016-07-14 14:54     ` Eli Zaretskii
2016-07-15  3:22       ` npostavs
2016-07-15  7:21         ` Eli Zaretskii
2016-07-16  2:46           ` npostavs [this message]
2016-07-16  6:43             ` Eli Zaretskii
2016-07-16 17:03               ` npostavs
2016-07-16 17:20                 ` Lars Ingebrigtsen
2016-07-17 16:20       ` npostavs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mvlie1vv.fsf@users.sourceforge.net \
    --to=npostavs@users.sourceforge.net \
    --cc=23967@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.