Subject: bug#23967: 25.1.50; Slow compilation of ns-win.el

From: Eli Zaretskii <[email-masked]>
Date: Thu, 14 Jul 2016 17:54:23 +0300

> From: Noam Postavsky <[email-masked]>
> Date: Wed, 13 Jul 2016 17:15:15 -0400
> Cc: Lars Ingebrigtsen <[email-masked]>, [email-masked]
> 
> I ran the profiler on a compilation of ucs-normalize.el and found 2
> easy optimizations (ucs-normalize-block-compose-chars was using
> with-temp-buffer in a loop, so I lifted the it out of the loop; using
> regexp-opt-charset instead of regexp-opt saves some char-to-string
> conversion, sorting, and duplicate deletion). The attached patch
> brings the compilation down from 2.5 seconds to 0.8 seconds in my
> normal running Emacs, and using the bootstrap-emacs command posted by
> Lars (swapping ../lisp/international/ucs-normalize.el for
> ../lisp/term/ns-win.el) from 1m30s to 7s.

LGTM, thanks.

However, I'm worried that we have no test for ucs-normalize, so it's
hard to be sure the non-trivial functionality is unchanged, even
though your changes are pretty straightforward.

How about adding a test that uses the data in this file:

  http://www.unicode.org/Public/UNIDATA/NormalizationTest.txt

ucs-normalize claims to have passed an old version of this, but I see
no existing way of re-running that test, did I miss something?

I'd feel much safer if the tests all pass at least as they did with
the old version.

> Could we call `byte-compile' on the byte-compiler functions after loading them?

Maybe, you will have to try.  The bootstrap of the byte compiler is
somewhat tricky, given all the dependencies (see COMPILE_FIRST in
lisp/Makefile.in).

Thanks.