From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jim Porter Newsgroups: gmane.emacs.bugs Subject: bug#50806: 27.2; [PATCH] Optimize ansi-color.el Date: Sun, 3 Oct 2021 10:53:20 -0700 Message-ID: <25ed8125-3f78-c9c9-9324-d75e48e702c6@gmail.com> References: <87tui8wakb.fsf@miha-pc> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33122"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Lars Ingebrigtsen To: miha@kamnitnik.top, 50806@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Oct 03 19:54:12 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mX5gg-0008Ue-Nw for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 03 Oct 2021 19:54:10 +0200 Original-Received: from localhost ([::1]:60964 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mX5gd-0007FY-GH for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 03 Oct 2021 13:54:07 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54766) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mX5gX-0007FM-Vj for bug-gnu-emacs@gnu.org; Sun, 03 Oct 2021 13:54:01 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:51571) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mX5gX-0007l7-OF for bug-gnu-emacs@gnu.org; Sun, 03 Oct 2021 13:54:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mX5gX-0006QA-JX for bug-gnu-emacs@gnu.org; Sun, 03 Oct 2021 13:54:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Jim Porter Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 03 Oct 2021 17:54:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50806 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 50806-submit@debbugs.gnu.org id=B50806.163328361124641 (code B ref 50806); Sun, 03 Oct 2021 17:54:01 +0000 Original-Received: (at 50806) by debbugs.gnu.org; 3 Oct 2021 17:53:31 +0000 Original-Received: from localhost ([127.0.0.1]:34884 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mX5g3-0006PN-8A for submit@debbugs.gnu.org; Sun, 03 Oct 2021 13:53:31 -0400 Original-Received: from mail-pg1-f171.google.com ([209.85.215.171]:40659) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mX5fz-0006P8-No for 50806@debbugs.gnu.org; Sun, 03 Oct 2021 13:53:29 -0400 Original-Received: by mail-pg1-f171.google.com with SMTP id h3so3775192pgb.7 for <50806@debbugs.gnu.org>; Sun, 03 Oct 2021 10:53:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:references:from:cc:message-id:date:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=XeJCPsLjF/9ipt+KG41SlYtsVFf10DAkOSbq0VrjEC8=; b=ejRPUepBHbUrVgVTC+Yr2/ArxzkiezPYri5PZZhEloI66E8KuxdAr8sJui+Er0qNG2 RfOmefGWypWj25Uq8N6MUfocb/kfCExn/kq6jiKg8OVzfW8K26K+uTzTFrjV6pfMRHHM IcKgPlLl3ePC0CxHVVzZ67skEhoJKil1mJCR5o4NR+JzLzGP5knL/3dKe/+UkHOF4YzS 3acdl03Z6BLA1a/eQRS6ZId28XcfUEgH48zTNFjm+UXvjgsqptsxSFdmPP7hhyWh1FrC 992XqGMny0MVlxeIh35HlIqtGfrX3UeFUWTj/K0Xb0LmJHUHOuI/MMjBHzZQP7plxGhT he3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:references:from:cc:message-id:date :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=XeJCPsLjF/9ipt+KG41SlYtsVFf10DAkOSbq0VrjEC8=; b=jgPjZShzzSfDQXmHGimLlFUYOgQyGmcsdhYoagHva5mF/BDkyb8AEdxRd44LQM+Pen qIW0GbbwVjDMcIhnZRGe5tdD6Pk7PZ0QTwyxCAR4J9biuW7pBrOrjaNpbB1DHcPXpGTm +70T3007FCGCXdRZvRXoJYV5kXjasSdgCzGE+8ZMdMOIxlK/8Sbrc0yO4TLQryDrxHVI qItUVgVT8av3Vi9skdF3YiO8TSBZHydnHAff1B/0Fyjhb0fFtrOQPrPK8SXCpFVPA1UZ 7ovPcyg1H4gqKPoBzI5L3rjFLLtmsM1kVmMebBZKkk5H3Hwr7+ailyzQI7gAX/1589cY Rq6g== X-Gm-Message-State: AOAM532kIGbVP5eZQsnyex0mb9rr7VbSnni39QEKXK1lAdWfCNf0jsxF dfYuroiNizQ7fweNJr92Hjs= X-Google-Smtp-Source: ABdhPJzwyeGepcGBg2Otes17eSXo8yoONoUnd82ZdL+lGFtDPrWmf10Rj+/ubEiHYr/bvhqNpXFqJw== X-Received: by 2002:a63:7405:: with SMTP id p5mr7434529pgc.426.1633283601834; Sun, 03 Oct 2021 10:53:21 -0700 (PDT) Original-Received: from [192.168.1.2] (cpe-76-168-148-233.socal.res.rr.com. [76.168.148.233]) by smtp.googlemail.com with ESMTPSA id u12sm13351714pjr.2.2021.10.03.10.53.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 03 Oct 2021 10:53:21 -0700 (PDT) In-Reply-To: <87tui8wakb.fsf@miha-pc> Content-Language: en-US X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:216289 Archived-At: (Apologies for the delay in replying; the original message hit my spam filter, and I only saw the followup. CC'ing Lars, who reviewed my patches and can hopefully provide a more-helpful review than me with my shaky Lisp skills.) On 9/25/2021 3:32 PM, miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors wrote: > Attached patch speeds up ansi-color. It tries to eliminate as many > allocations (cons and list) as possible. > > Benchmarks, recorded in emacs -q, are in the second attachments. With > the patch applied, there is a 26% speedup in elapsed time, mostly > because the garbage collector has to take care of less allocations. Sounds good to me. I did some very light benchmarking on my patches, but only to make sure I didn't make things too much slower (hopefully I succeeded). Making it faster would definitely be nice. > Two less important side notes: > > 1) This patch additionally makes it very straight forward to add support > for ANSI color codes 38 and 48 allowing 256-colors and 24bit > full-color. I plan to submit such a patch later (for both ansi-color > and term-mode). Glad to hear it! I was planning on doing this for Emacs 29, but if you've already got something in mind for this, feel free to work on it. Another thing that might be worth looking at would be improving term.el's support for "basic" ANSI escapes; I think it only does bold, underline, and inverse. Also, the inverse implementation seems a bit over-complicated when it could just use the :inverse-video face attribute instead. > 2) Two vector variables, that were recently added by Jim, were merged > into one. Adding him as CC. I see you posted an updated patch that doesn't merge these vectors. I don't have an opinion here, although if we do merge them, it would probably be nice to get that into Emacs 28; other packages might conceivably want to let-bind those[1]. [1] See man.el, which let-binds `ansi-color-basic-faces-vector' in `Man-fontify-manpage'. That's for the basic faces, not the colors, but the same idea should apply.