From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#72689: 31.0.50; Proposal to improve string-pixel-width Date: Sun, 18 Aug 2024 12:23:14 +0300 Message-ID: <86zfpayykd.fsf@gnu.org> References: <54d1d667-55d0-41fc-9eec-38b3881d799b@orange.fr> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17003"; mail-complaints-to="usenet@ciao.gmane.io" Cc: da_vid@orange.fr, 72689@debbugs.gnu.org To: Jim Porter Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Aug 18 11:24:47 2024 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 1sfc9W-0004Jk-Of for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 18 Aug 2024 11:24:46 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sfc9D-00084S-O2; Sun, 18 Aug 2024 05:24:27 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sfc99-00083w-81 for bug-gnu-emacs@gnu.org; Sun, 18 Aug 2024 05:24:23 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sfc98-0008N1-GD for bug-gnu-emacs@gnu.org; Sun, 18 Aug 2024 05:24:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:From:Date:To:Subject; bh=+7u74pGIp6EJ6++lp25lotKLFVKVBFzzybnGhgliqDU=; b=ZEuK7Kh6N69DeTC9ItQWgeKmG+vKECBxcaGtKxCDj974KqWO4BSl5HuXjy2CeRoblRqu7etTKQHTniZJ2XtB9RjWsVVvcmMLrX534J9MilTvo4gP/8B45dLeDNQM+NWahq4M51XxnTw1mXbsRNVzxdGoaZ0+bSXoxH+LMkg5mXUgR7drV+yejThy8ckbQLNg5wV4A7qOOI0RJGRm9nhn15UO7IczlDYjIbSM36BRt1AKvB/81pjzoMp+ohzUUt7RgAi/ojEG2ZT0TKGdZM8QIWwjvevj55XonscxJrg7JEUeJNToPyWPoybyTUNpO3LqwvsfUjbsvGqzVxa5IsIOqQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sfc9m-0008Er-H9 for bug-gnu-emacs@gnu.org; Sun, 18 Aug 2024 05:25:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 18 Aug 2024 09:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72689 X-GNU-PR-Package: emacs Original-Received: via spool by 72689-submit@debbugs.gnu.org id=B72689.172397304731572 (code B ref 72689); Sun, 18 Aug 2024 09:25:02 +0000 Original-Received: (at 72689) by debbugs.gnu.org; 18 Aug 2024 09:24:07 +0000 Original-Received: from localhost ([127.0.0.1]:55420 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sfc8t-0008D9-EQ for submit@debbugs.gnu.org; Sun, 18 Aug 2024 05:24:07 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:36034) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sfc8s-0008Cf-5A for 72689@debbugs.gnu.org; Sun, 18 Aug 2024 05:24:06 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sfc85-0008Er-4U; Sun, 18 Aug 2024 05:23:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=+7u74pGIp6EJ6++lp25lotKLFVKVBFzzybnGhgliqDU=; b=HNB2XFi3Mzyc eUcrflCtZCLtRz4WWaBZMFLomEDf3Zc3FIO4U+XjgPkEbym6kAnwJZ3BhxX+8bvunfckiZKcaRMmp oudDiULyFADG2pyX9ctrbcesqNzrx33eCFjEeZ1ERu3d8IeiOBdlGwvrULwrScu6fj6qW/2I5srat DzJCWgcXdCh8gO92IEwWVXWsTUz6SItIe0TrQJtlsw28Te4doyQcPv9zg0vVwxhsW4nEACwmsYKn1 dE0VEdgutVfAFRASZkqlbNCfzXWKoBvTYpO7xxmTrXAL6/+pNKN5lm/81eFXWZanrRG6rf1XoMWJB xza+WNLkxSt+VaMipv20sA==; In-Reply-To: (message from Jim Porter on Sat, 17 Aug 2024 23:12:21 -0700) 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:290305 Archived-At: > Date: Sat, 17 Aug 2024 23:12:21 -0700 > From: Jim Porter > > On 8/17/2024 3:03 PM, David Ponce via Bug reports for GNU Emacs, the > Swiss army knife of text editors wrote: > > I propose the attached patch to make string-pixel-width faster while > > using less memory, as shown by the following results of a basic > > benchmark run in emacs -Q to compare the current implementation and this > > proposal:[snip] > > > - (insert (propertize string 'line-prefix nil 'wrap-prefix nil)) > > + (insert string) > > + ;; Prefer `remove-text-properties' to `propertize' to avoid > > + ;; creating a new string on each call. > > + (remove-text-properties > > + (point-min) (point-max) '(line-prefix nil wrap-prefix nil)) > > Is this change safe? It's how this function behaved since day one. These properties are meaningless for a string's width, since for them to take effect the string should be at the beginning of a screen line, which is not a property of an arbitrary string. > I suppose most of the time, this wouldn't matter, > but I could imagine a case where a caller wanted the pixel-width of a > string that had one of those properties set, and they'd want those > properties to be preserved (e.g. if the string was to be inserted into a > buffer later). If a Lisp program wants to know the width of the line-prefix, it can do that separately. > I'm not sure how much this matters, but I always get a bit nervous about > a function changing something about one of its arguments when it's not > obvious. The argument isn't changed, only the text inserted into the temporary buffer gets its properties changed.