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#56347: Optimize/simplify STRING_SET_MULTIBYTE Date: Sat, 02 Jul 2022 20:06:38 +0300 Message-ID: <83h73zbg0x.fsf@gnu.org> References: <83pmioca3h.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40389"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 56347@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jul 02 19:07:10 2022 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 1o7gaM-000AMS-55 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 02 Jul 2022 19:07:10 +0200 Original-Received: from localhost ([::1]:35406 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o7gaK-0004Ue-Sx for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 02 Jul 2022 13:07:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45480) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o7gaE-0004UK-L8 for bug-gnu-emacs@gnu.org; Sat, 02 Jul 2022 13:07:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48882) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o7gaE-00056i-7p for bug-gnu-emacs@gnu.org; Sat, 02 Jul 2022 13:07:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1o7gaE-0006zU-0A for bug-gnu-emacs@gnu.org; Sat, 02 Jul 2022 13:07: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: Sat, 02 Jul 2022 17:07:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56347 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 56347-submit@debbugs.gnu.org id=B56347.165678161826863 (code B ref 56347); Sat, 02 Jul 2022 17:07:01 +0000 Original-Received: (at 56347) by debbugs.gnu.org; 2 Jul 2022 17:06:58 +0000 Original-Received: from localhost ([127.0.0.1]:42779 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o7gaA-0006zC-Jo for submit@debbugs.gnu.org; Sat, 02 Jul 2022 13:06:58 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:60486) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o7ga8-0006yu-Cd for 56347@debbugs.gnu.org; Sat, 02 Jul 2022 13:06:57 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:50846) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o7ga2-00055s-JD; Sat, 02 Jul 2022 13:06:50 -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=8KGeVnnqULfOsiJwL0woN50QfF5cBHFhyOtxY7gt+eA=; b=nbUSeGJI8Su+ k/d3mFek0cAzNGk2dZAvoN1k9qMakv8/3gOYjZeDVOq9xKIo3n/S8uHYVwtnXy/Lw9GLyQK52kwFi GRmRXD4x5Lw81ip77hS311f9HumhkZwFbSych0cqRSXEDPz2v6qEUJ1qoqRFj2sM4rlvrbpKLhpJ6 v2OOVcD1NVyZUaHwTnCIqjKNXYsCet0vi8OlFrFpr/1eEOw2GeYPdJ9I7SpiaAIbDE3yDOTSu4i0w BwVTpkY2XQTpXvZrEtbd+zCD0Oj6E9s53CIk7PMp2MPDP+15aLOVTeJmB5f7fp2y6aEae8umgQ05Z LPVIrfdRQ98zijMlofn4Ng==; Original-Received: from [87.69.77.57] (port=1327 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o7ga2-0005cf-1N; Sat, 02 Jul 2022 13:06:50 -0400 In-Reply-To: (message from Stefan Monnier on Sat, 02 Jul 2022 12:49:53 -0400) 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:235939 Archived-At: > From: Stefan Monnier > Cc: 56347@debbugs.gnu.org > Date: Sat, 02 Jul 2022 12:49:53 -0400 > > >> --- a/src/composite.c > >> +++ b/src/composite.c > >> @@ -1879,11 +1879,7 @@ Otherwise (for terminal display), FONT-OBJECT must be a terminal ID, a > >> for (i = SBYTES (string) - 1; i >= 0; i--) > >> if (!ASCII_CHAR_P (SREF (string, i))) > >> error ("Attempt to shape unibyte text"); > >> - /* STRING is a pure-ASCII string, so we can convert it (or, > >> - rather, its copy) to multibyte and use that thereafter. */ > >> - Lisp_Object string_copy = Fconcat (1, &string); > >> - STRING_SET_MULTIBYTE (string_copy); > >> - string = string_copy; > >> + /* STRING is a pure-ASCII string, so we can treat it as multibyte. */ > > > > Did you actually try your change in the situations where this problem > > pops up? AFAIR, the code makes a copy of the string for good reasons: > > the rest of handling of the string down the line barfs if we keep a > > multibyte string here. > > Of course, if we really do need a multibyte copy of the string, I can > change the patch to call `Fstring_to_multibyte` instead of `Fconcat`. Why not call make_multibyte_string directly?