From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Mark Oteiza Newsgroups: gmane.emacs.bugs Subject: bug#28302: 26.0.50; [PATCH] Make ucs-names a hash table Date: Thu, 31 Aug 2017 10:46:16 -0400 Message-ID: <87tw0n4wxz.fsf@holos> References: <87r2vsqqeo.fsf@holos> <83tw0n25xo.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1504190853 15141 195.159.176.226 (31 Aug 2017 14:47:33 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 31 Aug 2017 14:47:33 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) Cc: 28302@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Aug 31 16:47:23 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dnQkO-0002re-CO for geb-bug-gnu-emacs@m.gmane.org; Thu, 31 Aug 2017 16:47:08 +0200 Original-Received: from localhost ([::1]:56165 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dnQkV-0008Qu-7D for geb-bug-gnu-emacs@m.gmane.org; Thu, 31 Aug 2017 10:47:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50508) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dnQkL-0008Pl-R4 for bug-gnu-emacs@gnu.org; Thu, 31 Aug 2017 10:47:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dnQkI-00084b-Hp for bug-gnu-emacs@gnu.org; Thu, 31 Aug 2017 10:47:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:57242) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dnQkI-00084V-E4 for bug-gnu-emacs@gnu.org; Thu, 31 Aug 2017 10:47:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dnQkI-0004sx-4u for bug-gnu-emacs@gnu.org; Thu, 31 Aug 2017 10:47:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mark Oteiza Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 31 Aug 2017 14:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 28302 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 28302-submit@debbugs.gnu.org id=B28302.150419078618716 (code B ref 28302); Thu, 31 Aug 2017 14:47:02 +0000 Original-Received: (at 28302) by debbugs.gnu.org; 31 Aug 2017 14:46:26 +0000 Original-Received: from localhost ([127.0.0.1]:37685 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dnQjh-0004ro-MT for submit@debbugs.gnu.org; Thu, 31 Aug 2017 10:46:25 -0400 Original-Received: from mail-qt0-f169.google.com ([209.85.216.169]:38778) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dnQjg-0004rc-6Z for 28302@debbugs.gnu.org; Thu, 31 Aug 2017 10:46:24 -0400 Original-Received: by mail-qt0-f169.google.com with SMTP id w42so3845633qtg.5 for <28302@debbugs.gnu.org>; Thu, 31 Aug 2017 07:46:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=udel-edu.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=bEX5GTcUXRbnfRS7s/4lOpZkmmtLWwyWMTSFpii9ATw=; b=DeXrzo6s5KD9pGWG/o8SQ+5RdiYHLkPAKNbU7bB21xaBaIj8+s/TjUso0fgrvA+TwM A9dMljVz7OvFiYPlU8QlVludrhut99VCWl4A2zKJcCjlfYNR+lKwvRZQ/Dru8rSEraAU /osNL5t9hWs8slNFZc/Zjm/b5tnnC9XmKko4YrnMMsz921PStycHbCQu2zOwQk71G1uK JZ/lPpOrPgxeP9xpbKAomyDclVJQh6N8K30Hdioe8ppUOlTnPy1YodbPnkSK4Tpq4uw6 Bv4NfMwbalIRd6fjmgqmRJnuJnK5M28NSYCRNRPuaChWJCcwFHKcvv/7CJIKOe43488Q mSTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=bEX5GTcUXRbnfRS7s/4lOpZkmmtLWwyWMTSFpii9ATw=; b=MxG+2/HH8L8gglpZ/I5qZozZ1YGcH+wMpSmpbeq125SKRBwOEbGcc4MIoT6XIII++q F0iV0ab8WyR6ZtWOpx0ZgWVfO2Y+mx4iY0Rdp/hMqnvu+V76+dgp1PMhmWGIfWHouemB PuJwEs5gp28V2uwMD1d0AYAf89OPQb2OBY52zcr7dGjKdel3WnoVJJeCJW0sA7Pyzt3x nShdgiiZu388xB5UqUdU29RL5ZfAOXQ+kO1tiEJleUvrlfWJcoFl1Q+DC7R4UCRvdsIX sIzWYXRz0N7KgGWlVoURiDEvEWrKLEJtaitl2cEVuUGwFyvxpGr7VusIUhWQ+atA7dLh TWIA== X-Gm-Message-State: AHPjjUjgpMDqXdU3xL2md/2lZiQZb8n6CM6QSVES3mBDXfelGuYzMSfy fCKQL8mwZ57y3UWiIVdJAg== X-Google-Smtp-Source: ADKCNb5Q97UMLfM5LQlOMKKE9E+FtLYTqMesTaynSjF8a098ibDwj0nvj1Jc5EpOZanatQT0PrbnTg== X-Received: by 10.200.55.233 with SMTP id e38mr7288167qtc.12.1504190778257; Thu, 31 Aug 2017 07:46:18 -0700 (PDT) Original-Received: from holos.localdomain (pool-173-64-88-95.bltmmd.fios.verizon.net. [173.64.88.95]) by smtp.gmail.com with ESMTPSA id g54sm5692177qtk.60.2017.08.31.07.46.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2017 07:46:17 -0700 (PDT) Original-Received: by holos.localdomain (Postfix, from userid 1000) id 6032A6877C; Thu, 31 Aug 2017 10:46:16 -0400 (EDT) In-Reply-To: <83tw0n25xo.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 31 Aug 2017 17:00:19 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:136405 Archived-At: Eli Zaretskii writes: >> From: Mark Oteiza >> Date: Thu, 31 Aug 2017 01:04:15 -0400 >> >> I seem to remember there having been complaints about ucs-names preview >> being slow. I was curious about how much of that time was spent >> assoc'ing every element of a roughly n = 42k element long alist, and so >> tried making it a hash table instead. The result is a drastic speedup >> of C-x 8 RET TAB, presumably this makes the operation O(n) vs O(n^2). > > Thanks, this is a very good change. Please make sure (if you haven't > already) that it survives bootstrap. > > Also, there are other places which assume that ucs-names is an alist, > so I guess this is not the full final patch? Yes, since posting I found the other two places where ucs-names is used and have made changes there. > And this should be mentioned in NEWS under incompatible Lisp changes, > as ucs-names debuted in Emacs 23.1, and there could be some uses of it > outside Emacs proper. Thanks, patch with additional changes attached. I don't really like repeating the string in descr-text.el, but BEL is the only outlier and I think it would be overkill to write a rassoc analog. diff --git a/etc/NEWS b/etc/NEWS index e8d6ea9c6d..e8f6aec9ef 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1153,6 +1153,9 @@ table implementation. This uses a new bytecode op 'switch', which isn't compatible with previous Emacs versions. This functionality can be disabled by setting 'byte-compile-cond-use-jump-table' to nil. +--- +** The variable 'ucs-names' is now a hash table. + ** 'C-up', 'C-down', 'C-left' and 'C-right' are now defined in term mode to send the same escape sequences that xterm does. This makes things like forward-word in readline work. diff --git a/lisp/descr-text.el b/lisp/descr-text.el index 6f36bbed68..b3c96988dd 100644 --- a/lisp/descr-text.el +++ b/lisp/descr-text.el @@ -617,16 +617,16 @@ describe-char (list (let* ((names (ucs-names)) (name - (or (when (= char 7) + (or (when (= char ?\a) ;; Special case for "BELL" which is ;; apparently the only char which ;; doesn't have a new name and whose ;; old-name is shadowed by a newer char ;; with that name (bug#25641). - (car (rassoc char names))) + "BELL (BEL)") (get-char-code-property char 'name) (get-char-code-property char 'old-name)))) - (if (and name (assoc-string name names)) + (if (and name (gethash name names)) (format "type \"C-x 8 RET %x\" or \"C-x 8 RET %s\"" char name) diff --git a/lisp/leim/quail/latin-ltx.el b/lisp/leim/quail/latin-ltx.el index 6c5afcd4f9..778706a451 100644 --- a/lisp/leim/quail/latin-ltx.el +++ b/lisp/leim/quail/latin-ltx.el @@ -75,20 +75,20 @@ (`(,seq ,re) (let ((count 0) (re (eval re t))) - (dolist (pair (ucs-names)) - (let ((name (car pair)) - (char (cdr pair))) - (when (and (characterp char) ;; Ignore char-ranges. - (string-match re name)) - (let ((keys (if (stringp seq) - (replace-match seq nil nil name) - (funcall seq name char)))) - (if (listp keys) - (dolist (x keys) - (setq count (1+ count)) - (push (list x char) newrules)) - (setq count (1+ count)) - (push (list keys char) newrules)))))) + (maphash + (lambda (name char) + (when (and (characterp char) ;; Ignore char-ranges. + (string-match re name)) + (let ((keys (if (stringp seq) + (replace-match seq nil nil name) + (funcall seq name char)))) + (if (listp keys) + (dolist (x keys) + (setq count (1+ count)) + (push (list x char) newrules)) + (setq count (1+ count)) + (push (list keys char) newrules))))) + (ucs-names)) ;; (message "latin-ltx: %d mappings for %S" count re) )))) (setq newrules (delete-dups newrules)) @@ -206,7 +206,7 @@ ((lambda (name char) (let* ((base (concat (match-string 1 name) (match-string 3 name))) - (basechar (cdr (assoc base (ucs-names))))) + (basechar (gethash base (ucs-names)))) (when (latin-ltx--ascii-p basechar) (string (if (match-end 2) ?^ ?_) basechar)))) "\\(.*\\)SU\\(?:B\\|\\(PER\\)\\)SCRIPT \\(.*\\)")