From debbugs-submit-bounces@debbugs.gnu.org Fri Jul 01 19:32:31 2022 Received: (at submit) by debbugs.gnu.org; 1 Jul 2022 23:32:31 +0000 Received: from localhost ([127.0.0.1]:39349 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o7Q7c-0002U5-KR for submit@debbugs.gnu.org; Fri, 01 Jul 2022 19:32:30 -0400 Received: from lists.gnu.org ([209.51.188.17]:36758) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o7Q7Z-0002Tw-OR for submit@debbugs.gnu.org; Fri, 01 Jul 2022 19:32:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43066) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o7Q7Z-00005w-Hy for bug-gnu-emacs@gnu.org; Fri, 01 Jul 2022 19:32:21 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:46435) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o7Q7X-00029A-0T for bug-gnu-emacs@gnu.org; Fri, 01 Jul 2022 19:32:20 -0400 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id D4809100163 for ; Fri, 1 Jul 2022 19:32:16 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 66E5D10012C for ; Fri, 1 Jul 2022 19:32:15 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1656718335; bh=H3mwfhXnXV0oSZCFg+qnpvpQUEXIQ9mI648JQg4lYN8=; h=From:To:Subject:Date:From; b=j8VCWg85pvW3/rqv37hKtQffDnXpoNHSQfp1RM+Ph17w/Vxn9aXtj0aPrD2L1sicR 53Yz/uJHX8uNK6IX97uMzGgnVlb2Ed4PlnsrRDtGuEkALRCuj1EPiQtQ3F5Jr7yxGa W8pvUurkT87Zn55q7XH9/Ngc37a1uSxyghL8ckBbCUHXIOOuQjFUfK7V0bcdwNfJrP wyGTltegNK8xo0snyPFxzrNYigTQlhrjV/piPDaFolnTPkeAAgbiX8zv6HmsI5af0k 5o87ywQpMOmRTt3jIFJhfomTedt1+wOJs738OTFUGdqClbDgC/rI4Ij/Ev+xu7/D6P BzvMeTnLnRldw== Received: from alfajor (unknown [45.72.196.165]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 43F1612013F for ; Fri, 1 Jul 2022 19:32:15 -0400 (EDT) From: Stefan Monnier To: bug-gnu-emacs@gnu.org Subject: Optimize/simplify STRING_SET_MULTIBYTE Date: Fri, 01 Jul 2022 19:32:05 -0400 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.044 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain T_SCC_BODY_TEXT_LINE -0.01 - X-SPAM-LEVEL: Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --=-=-= Content-Type: text/plain Tags: patch Tags: patch The patch below simplifies code around STRING_SET_MULTIBYTE. Any objection? Stefan In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnux32, GTK+ Version 3.24.34, cairo version 1.16.0) of 2022-06-30 built on alfajor Repository revision: 2c31b0d5b84471e8b1fa5737b37cf4c241aec036 Repository branch: work Windowing system distributor 'The X.Org Foundation', version 11.0.12101003 System Description: Debian GNU/Linux bookworm/sid Configured using: 'configure -C --enable-checking --enable-check-lisp-object-type --with-modules --with-cairo --with-tiff=ifavailable 'CFLAGS=-Wall -g3 -Og -Wno-pointer-sign' PKG_CONFIG_PATH=/home/monnier/lib/pkgconfig' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=set-multibyte.patch diff --git a/src/composite.c b/src/composite.c index 4d69702171f..fb0c51821a5 100644 --- 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. */ } frombyte = string_char_to_byte (string, frompos); } diff --git a/src/lisp.h b/src/lisp.h index 7be2e5d38dc..9f2e7785d2f 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -1637,12 +1637,10 @@ #define STRING_SET_UNIBYTE(STR) \ /* Mark STR as a multibyte string. Assure that STR contains only ASCII characters in advance. */ -#define STRING_SET_MULTIBYTE(STR) \ - do { \ - if (XSTRING (STR)->u.s.size == 0) \ - (STR) = empty_multibyte_string; \ - else \ - XSTRING (STR)->u.s.size_byte = XSTRING (STR)->u.s.size; \ +#define STRING_SET_MULTIBYTE(STR) \ + do { \ + eassert (XSTRING (STR)->u.s.size > 0); \ + XSTRING (STR)->u.s.size_byte = XSTRING (STR)->u.s.size; \ } while (false) /* Convenience functions for dealing with Lisp strings. */ --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 02 02:17:03 2022 Received: (at 56347) by debbugs.gnu.org; 2 Jul 2022 06:17:03 +0000 Received: from localhost ([127.0.0.1]:39564 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o7WRD-0002y1-Ge for submit@debbugs.gnu.org; Sat, 02 Jul 2022 02:17:03 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51972) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o7WRA-0002xS-4U for 56347@debbugs.gnu.org; Sat, 02 Jul 2022 02:17:02 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:44686) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o7WR4-0003ob-OE; Sat, 02 Jul 2022 02:16:54 -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=Cs5hitmAVTEkqDxKokaKJJyIBNQ2zyQIrXVOSXRAbDc=; b=ZkKmpWvrUvmw yDfYksgfdM9vb0eW//Trf1+jZieP93sYEJwBpVdPgv7iQ1yTsyqoO68B6tohIoqCxgCKiXgczx38k KxdtcTZS4nKME05GmWwYGS8GMo8iO3aiSf/b4ggA1Ed9ok8lBpVzKTh6rFjdzDRTkjZnE2x4AEyr2 MgOhkZlQf1KN5KLZwqAQomNnKf5U+guQ8XL4NAP619U1S2udHvN1FksdHKUHI5TiRubXLtbWWlIbB QzFIOiAgK9JxsJvPTJ1j0U2fbqdX9D/YAx5sloSL1dl5LONxxPzPEDpggqSrYoMja9TZD4T+qOiQc aTiKHrKuLv/fiRSmCG6jlA==; Received: from [87.69.77.57] (port=4989 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 1o7WR4-0002st-8O; Sat, 02 Jul 2022 02:16:54 -0400 Date: Sat, 02 Jul 2022 09:17:06 +0300 Message-Id: <83pmioca3h.fsf@gnu.org> From: Eli Zaretskii To: Stefan Monnier In-Reply-To: (bug-gnu-emacs@gnu.org) Subject: Re: bug#56347: Optimize/simplify STRING_SET_MULTIBYTE References: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 56347 Cc: 56347@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Date: Fri, 01 Jul 2022 19:32:05 -0400 > From: Stefan Monnier via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > The patch below simplifies code around STRING_SET_MULTIBYTE. > Any objection? Rationale? Simplification in these cases is minimal, almost non-existent, so it cannot be the only rationale. > --- 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. > --- a/src/lisp.h > +++ b/src/lisp.h > @@ -1637,12 +1637,10 @@ #define STRING_SET_UNIBYTE(STR) \ > > /* Mark STR as a multibyte string. Assure that STR contains only > ASCII characters in advance. */ > -#define STRING_SET_MULTIBYTE(STR) \ > - do { \ > - if (XSTRING (STR)->u.s.size == 0) \ > - (STR) = empty_multibyte_string; \ > - else \ > - XSTRING (STR)->u.s.size_byte = XSTRING (STR)->u.s.size; \ > +#define STRING_SET_MULTIBYTE(STR) \ > + do { \ > + eassert (XSTRING (STR)->u.s.size > 0); \ > + XSTRING (STR)->u.s.size_byte = XSTRING (STR)->u.s.size; \ > } while (false) > > /* Convenience functions for dealing with Lisp strings. */ You want to disallow uses of empty_multibyte_string? why? From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 02 03:43:42 2022 Received: (at control) by debbugs.gnu.org; 2 Jul 2022 07:43:42 +0000 Received: from localhost ([127.0.0.1]:39650 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o7Xn4-0005LZ-5z for submit@debbugs.gnu.org; Sat, 02 Jul 2022 03:43:42 -0400 Received: from mail-pf1-f173.google.com ([209.85.210.173]:42694) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o7Xmz-0005LF-HX for control@debbugs.gnu.org; Sat, 02 Jul 2022 03:43:40 -0400 Received: by mail-pf1-f173.google.com with SMTP id d17so4415895pfq.9 for ; Sat, 02 Jul 2022 00:43:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:mime-version:date:message-id:subject:to; bh=21abItV5O8/tbCcAUXKplj3VlGS/N85/qGTnQwwCFRE=; b=QjmOvfYtfpHpW1RIrb8geRrEl5WEZVZNIWAGuVgLcU2qUMzYh2uw1wv5mnXn0TxyWd m30ts8+prq33yN1oZPiSUIu3EM51BRq3VabZoAPEwmYTjF+6+UX/bjG1Y857RoGlcFGQ cb+/7xlyB+i88TewizcP/HvrHIArKEUdkBfS0esVT96qDg7h91Oy9t8MvK8gTN2UU7Sb iJSnyAkMiSyRouU+vC99v37823CLGsUoF1DCrQp3iSrEHB5cJKJA9u09aHde+fx+ZBaN nc1VBuK+EIfZQQWre3S2WmGLWctPjKW/27VFU0651y3kRN1bQx/YCNAruH8SCQ/Rbh6l EXyg== X-Gm-Message-State: AJIora804xAJwfJFgrgj/ANKTz8uR9prnEWloDW/LJ5c/NEKRQ2/kf6c 9tyDyN6QVS6UL5d0EaBFrsKuxai/bhJfHxr/k84SWUcG X-Google-Smtp-Source: AGRyM1vAy5lqUZWX29d0igQ6eX9huTW6t0X4pT9vqKQJajCdPDWZ3zByGvkm+c9DAB3+MMbxUhkruZqPqNlnTZ8OjJQ= X-Received: by 2002:a05:6a00:b48:b0:525:348b:438b with SMTP id p8-20020a056a000b4800b00525348b438bmr24437534pfo.2.1656747811719; Sat, 02 Jul 2022 00:43:31 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Sat, 2 Jul 2022 09:43:30 +0200 From: Stefan Kangas MIME-Version: 1.0 Date: Sat, 2 Jul 2022 09:43:30 +0200 Message-ID: Subject: control message for bug #56347 To: control@debbugs.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.5 (/) severity 56347 wishlist quit From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 02 12:12:23 2022 Received: (at 56347) by debbugs.gnu.org; 2 Jul 2022 16:12:23 +0000 Received: from localhost ([127.0.0.1]:42679 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o7fjK-00019q-UZ for submit@debbugs.gnu.org; Sat, 02 Jul 2022 12:12:23 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:20695) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o7fjI-00019c-O0 for 56347@debbugs.gnu.org; Sat, 02 Jul 2022 12:12:21 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 279F9440B56; Sat, 2 Jul 2022 12:12:15 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 682F2440950; Sat, 2 Jul 2022 12:12:13 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1656778333; bh=+ti7cNixsMPKP+qRdZFD5T4VIqPG9IdD8RxG9v9bkKU=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=nyHXSpkAulGopjdLPrUginBxhtHFxPx/NUl5dRmmNdsHoCQxJqvSlEX/0n/hb6LdQ mO2V4cOppQwSv234WvZ5RlRM3cz7rwp+yrcjj7TJqPxHwq/paVCO3unKHRL7NzekQP ZDq/x4TtcjXp/0b5dgIjL2skcJbfRY+YIxiVoE3LNRlqMUBuSZEdPv2LDghA9LfCpr /BUw74is8wfnRsSjIgOy31AzoIjs3NUpHxv41BjWGRFITJOCdntbz+LKp+0C1GMnw9 m5qfLNc7ubyp0aM964MP/ma/zDsQLlAEyGH7U3MFn3zGHQ8+hpeyJPFfLLDijLRtAv j6EOGvIRS8mEQ== Received: from alfajor (unknown [45.72.196.165]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 125FB1204A0; Sat, 2 Jul 2022 12:12:13 -0400 (EDT) From: Stefan Monnier To: Eli Zaretskii Subject: Re: bug#56347: Optimize/simplify STRING_SET_MULTIBYTE Message-ID: References: <83pmioca3h.fsf@gnu.org> Date: Sat, 02 Jul 2022 12:12:06 -0400 In-Reply-To: <83pmioca3h.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 02 Jul 2022 09:17:06 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.062 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain T_SCC_BODY_TEXT_LINE -0.01 - X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 56347 Cc: 56347@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) >> The patch below simplifies code around STRING_SET_MULTIBYTE. >> Any objection? > Rationale? STRING_SET_MULTIBYTE is fundamentally evil because it changes the nature of an object. Its current definition (like that of STRING_SET_UNIBYTE) is rather scary (it sometimes changes the nature of the arg passed to it, and sometimes replaces the arg with something else). >> --- 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? I don't even know how to go about doing that, no. > 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. [ I assume you meant "barfs if we keep a *uni*byte string here". ] Where? AFAICT `string` is only used in the subsequent code by passing it to `fill_gstring_header` and that function only passes that arg to `fetch_string_char_advance_no_check` and that function only looks at the string's SDATA, so as long as the sequence of bytes is consistent with a multibyte string (which we just checked with the ASCII_CHAR_P loop), I don't see any problem. >> --- a/src/lisp.h >> +++ b/src/lisp.h >> @@ -1637,12 +1637,10 @@ #define STRING_SET_UNIBYTE(STR) \ >> >> /* Mark STR as a multibyte string. Assure that STR contains only >> ASCII characters in advance. */ >> -#define STRING_SET_MULTIBYTE(STR) \ >> - do { \ >> - if (XSTRING (STR)->u.s.size == 0) \ >> - (STR) = empty_multibyte_string; \ >> - else \ >> - XSTRING (STR)->u.s.size_byte = XSTRING (STR)->u.s.size; \ >> +#define STRING_SET_MULTIBYTE(STR) \ >> + do { \ >> + eassert (XSTRING (STR)->u.s.size > 0); \ >> + XSTRING (STR)->u.s.size_byte = XSTRING (STR)->u.s.size; \ >> } while (false) >> >> /* Convenience functions for dealing with Lisp strings. */ > > You want to disallow uses of empty_multibyte_string? why? No, I want to reduce the scope of semantics of the macro, e.g. so it can be implemented as a function rather than a macro and so it doesn't magically substitute empty_multibyte_string into a variable that held something else. Stefan From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 02 12:24:20 2022 Received: (at 56347) by debbugs.gnu.org; 2 Jul 2022 16:24:20 +0000 Received: from localhost ([127.0.0.1]:42710 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o7fuu-0003ei-Iw for submit@debbugs.gnu.org; Sat, 02 Jul 2022 12:24:20 -0400 Received: from eggs.gnu.org ([209.51.188.92]:53830) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o7fus-0003eV-SY for 56347@debbugs.gnu.org; Sat, 02 Jul 2022 12:24:19 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:50232) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o7fun-00027V-Fw; Sat, 02 Jul 2022 12:24:13 -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=fbtb3YCY6GHoMMdP3peHXkuLS+DCwieDNvxi7hfYvyA=; b=lVhLsqcITPCA QgBlZ+HkoBckt1mezvTUa1fMg4aeN5QxK0CgPUAZNxiRcs5IA7D1sxlZe14ntwLk2dpGBKQvmKXf5 FW/gptBEsW2YGmnQ6X5HWZvf9ewiIEchAz4F2F8qjNyU5kvbjRsQNbn+XvKZBt8Pn2rBBqyC9DcKA PBV+6Ga4C3fJuyV5IfV1U4zM8QtgtSnpFQiVglWFHt9AkwR6LkR0J1zHKeIAFm7GrzZ6m/TR0Idx9 p2GnCgee3LiBhdwdu4QDLpW2Q7ezWcmZQR37AvSFGSCglp2UeEDVpYz+LtNvNvZFRQblHJxWTjJhJ O7tmgqBlVBQhStuXV0bo0A==; Received: from [87.69.77.57] (port=2699 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 1o7fum-00078m-WC; Sat, 02 Jul 2022 12:24:13 -0400 Date: Sat, 02 Jul 2022 19:24:02 +0300 Message-Id: <83letbbhzx.fsf@gnu.org> From: Eli Zaretskii To: Stefan Monnier In-Reply-To: (message from Stefan Monnier on Sat, 02 Jul 2022 12:12:06 -0400) Subject: Re: bug#56347: Optimize/simplify STRING_SET_MULTIBYTE References: <83pmioca3h.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 56347 Cc: 56347@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Stefan Monnier > Cc: 56347@debbugs.gnu.org > Date: Sat, 02 Jul 2022 12:12:06 -0400 > > STRING_SET_MULTIBYTE is fundamentally evil because it changes the nature > of an object. Its current definition (like that of STRING_SET_UNIBYTE) > is rather scary (it sometimes changes the nature of the arg passed to > it, and sometimes replaces the arg with something else). But do we have any alternatives? > >> - /* 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? > > I don't even know how to go about doing that, no. Make a character-composition rule that composes, say, two '-' characters, and then display a buffer where you have adjacent dashes. > > 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. > > [ I assume you meant "barfs if we keep a *uni*byte string here". ] Yes. > Where? I don't remember, sorry. > >> -#define STRING_SET_MULTIBYTE(STR) \ > >> - do { \ > >> - if (XSTRING (STR)->u.s.size == 0) \ > >> - (STR) = empty_multibyte_string; \ > >> - else \ > >> - XSTRING (STR)->u.s.size_byte = XSTRING (STR)->u.s.size; \ > >> +#define STRING_SET_MULTIBYTE(STR) \ > >> + do { \ > >> + eassert (XSTRING (STR)->u.s.size > 0); \ > >> + XSTRING (STR)->u.s.size_byte = XSTRING (STR)->u.s.size; \ > >> } while (false) > >> > >> /* Convenience functions for dealing with Lisp strings. */ > > > > You want to disallow uses of empty_multibyte_string? why? > > No, I want to reduce the scope of semantics of the macro, e.g. so it can > be implemented as a function rather than a macro and so it doesn't > magically substitute empty_multibyte_string into a variable that held > something else. But the effect is that you disallow calling STRING_SET_MULTIBYTE on an empty string, isn't it? From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 02 12:50:05 2022 Received: (at 56347) by debbugs.gnu.org; 2 Jul 2022 16:50:05 +0000 Received: from localhost ([127.0.0.1]:42752 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o7gJp-0004Mo-J8 for submit@debbugs.gnu.org; Sat, 02 Jul 2022 12:50:05 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:19680) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o7gJl-0004MB-QQ for 56347@debbugs.gnu.org; Sat, 02 Jul 2022 12:50:03 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 62AF9440B5F; Sat, 2 Jul 2022 12:49:56 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 4183E440B63; Sat, 2 Jul 2022 12:49:55 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1656780595; bh=mZop5i5NbHwivYB5VPx9BswzVr3scTT40qAWmXJKRCI=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=OSbJcrQ8j4eI5pmu0T/iQudvBi5dV8N2RLV973nLtjj0zqV/ncvT0jvdQDFOA3UYT zhAA4xyZYpXO8JE5U2//kd2eyWW1Xfc79QyW62lj5fsX1cuvwI5/Y3sN02X0JptyM4 KWIZMC8oJuD2Mvc0LycjKfSKxoNL92LntllbRpOJM/ojZbFK7QFM2AfKzoaW4PK3i1 gici3wfzsWAmA1i0tLhnsNM28HAZp233OYT+YRyybJ0HMNplylGDynX1cXUW7o2hSp 2LStZ/O/gS4VzGbmrdE9gojdnisWP8qTFOvDJoS+QCSD8+Y0crYWMKO5w9L//1i7Nn g+XoSDH6td2KA== Received: from alfajor (unknown [45.72.196.165]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 0ADCE1203D6; Sat, 2 Jul 2022 12:49:54 -0400 (EDT) From: Stefan Monnier To: Eli Zaretskii Subject: Re: bug#56347: Optimize/simplify STRING_SET_MULTIBYTE Message-ID: References: <83pmioca3h.fsf@gnu.org> Date: Sat, 02 Jul 2022 12:49:53 -0400 In-Reply-To: <83pmioca3h.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 02 Jul 2022 09:17:06 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.062 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain T_SCC_BODY_TEXT_LINE -0.01 - X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 56347 Cc: 56347@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) >> --- 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`. Stefan From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 02 13:06:58 2022 Received: (at 56347) by debbugs.gnu.org; 2 Jul 2022 17:06:58 +0000 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 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 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==; 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 Date: Sat, 02 Jul 2022 20:06:38 +0300 Message-Id: <83h73zbg0x.fsf@gnu.org> From: Eli Zaretskii To: Stefan Monnier In-Reply-To: (message from Stefan Monnier on Sat, 02 Jul 2022 12:49:53 -0400) Subject: Re: bug#56347: Optimize/simplify STRING_SET_MULTIBYTE References: <83pmioca3h.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 56347 Cc: 56347@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > 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? From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 02 13:58:04 2022 Received: (at 56347) by debbugs.gnu.org; 2 Jul 2022 17:58:04 +0000 Received: from localhost ([127.0.0.1]:42816 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o7hNc-0008J6-3Z for submit@debbugs.gnu.org; Sat, 02 Jul 2022 13:58:04 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:56522) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o7hNW-0008IZ-A2 for 56347@debbugs.gnu.org; Sat, 02 Jul 2022 13:58:02 -0400 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id C03D68076B; Sat, 2 Jul 2022 13:57:52 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 4FA3B80677; Sat, 2 Jul 2022 13:57:51 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1656784671; bh=zywp6iGqeBphMrS19gay0PxveD9V7AA7wVG221wuTG0=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=Co8oMVplOW3ee2NSK0cR4n+p40bKUqAhYELypwyuJJv7xM5YxCwt6UEbxb38o0YcM VQHI1daqepwP5KWUz9dcnBotgftutjhNke+lu63wZl6oyagBv4a47zaiMhepRhF/fE MNf7s2j+WW9n0EmmMdZD5Ni2YxIQzNni4xWEehOjnu7AWZHvdpw9f6MqbNjr2tmcb1 rNC2QBpjC1tr84Fz+VnuOsmU7oIYek0GSPBGf38il0MGga5AbY4lH0McX2LrvvDz9P e1CMxSszEduQKgQVpr1ToEmGs3GznkdEUG7TD8ucMtp282pPtoDXfHYgC9xAFrokrP 3/3PfHuzwDMCw== Received: from alfajor (unknown [45.72.196.165]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id EBF2E12056C; Sat, 2 Jul 2022 13:57:50 -0400 (EDT) From: Stefan Monnier To: Eli Zaretskii Subject: Re: bug#56347: Optimize/simplify STRING_SET_MULTIBYTE Message-ID: References: <83pmioca3h.fsf@gnu.org> <83h73zbg0x.fsf@gnu.org> Date: Sat, 02 Jul 2022 13:57:49 -0400 In-Reply-To: <83h73zbg0x.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 02 Jul 2022 20:06:38 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.054 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain T_SCC_BODY_TEXT_LINE -0.01 - X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 56347 Cc: 56347@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Why not call make_multibyte_string directly? That too, of course, Stefan From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 02 14:00:50 2022 Received: (at 56347) by debbugs.gnu.org; 2 Jul 2022 18:00:50 +0000 Received: from localhost ([127.0.0.1]:42821 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o7hQI-0008OZ-KQ for submit@debbugs.gnu.org; Sat, 02 Jul 2022 14:00:50 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:4522) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o7hQH-0008OG-53 for 56347@debbugs.gnu.org; Sat, 02 Jul 2022 14:00:49 -0400 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id C1E268076B; Sat, 2 Jul 2022 14:00:43 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 498CC80677; Sat, 2 Jul 2022 14:00:42 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1656784842; bh=rFnZ4pjQdAouvp1BVapUWCRZ6E2naE7dsa91m5PZPnA=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=pd0CH+Y1zZxn2YvqtRhNjZ+VJNfZlBOJsU8u4dNXCvNtSteWS1t1sqKnzlHrsb6dX vaqPOmVbXmdiNhVd0QIvB/DnGMvfUzd1fBLXj3mKm1ahKkQIVihnu70sOGu5yI1Qz6 BGVhKPE0K2031xNpdACq842avJc7qo234V14p0aooHlduiH8Rx/jqAvwCuoLXn6HiE gEMj9zC0LerTcMD80oRXJfMYbjFiuJ562fCxAEr2BjhbxAwK+Zz8Bc3LBVCl9Uaruz 7Kry2OQWAtefyOlGVQZuj0Gwye2QBKRP3+aEcpYJm0VfQwbfxZyT2MiUs91+fZB+gG N+X6RwJE8dZlw== Received: from alfajor (unknown [45.72.196.165]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 0C5E01201E5; Sat, 2 Jul 2022 14:00:41 -0400 (EDT) From: Stefan Monnier To: Eli Zaretskii Subject: Re: bug#56347: Optimize/simplify STRING_SET_MULTIBYTE Message-ID: References: <83pmioca3h.fsf@gnu.org> <83letbbhzx.fsf@gnu.org> Date: Sat, 02 Jul 2022 14:00:41 -0400 In-Reply-To: <83letbbhzx.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 02 Jul 2022 19:24:02 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.054 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain T_SCC_BODY_TEXT_LINE -0.01 - X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 56347 Cc: 56347@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) >> No, I want to reduce the scope of semantics of the macro, e.g. so it can >> be implemented as a function rather than a macro and so it doesn't >> magically substitute empty_multibyte_string into a variable that held >> something else. > But the effect is that you disallow calling STRING_SET_MULTIBYTE on an > empty string, isn't it? Yes. In my book, STRING_SET_*IBYTE should basically not exist: a string is created as unibyte or multibyte and never changes after that. And indeed because we only have a single copy of the two possible empty strings, they can't be changed between unibyte<->multibyte Stefan From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 02 14:31:58 2022 Received: (at 56347) by debbugs.gnu.org; 2 Jul 2022 18:31:58 +0000 Received: from localhost ([127.0.0.1]:42842 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o7huQ-0000iA-9P for submit@debbugs.gnu.org; Sat, 02 Jul 2022 14:31:58 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43598) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o7huN-0000hx-1k for 56347@debbugs.gnu.org; Sat, 02 Jul 2022 14:31:57 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:52048) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o7huH-0001Yr-Am; Sat, 02 Jul 2022 14:31:49 -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=jzlMMZsh8yiJDTfAAcIMXy5pTJPlx3ax5xlcpxwMw9c=; b=bNUZ8H4V2VAB Tpnl/kGto31KhMMN/O+9Lncbt6kVIMw6Ri/Km/CumIZbtHk6O7cgv6F0R+8hzISAulcbtU5fEoHcO fl65pBK7/lKhzlq9sqaAfUFwBsI9G5WQJxsrarGbWB2+86mT1all2FHlMrSeV9x1aVAWO4ePe4l4B qs1ES3YqxiL15WGIqr3KtiP7VxYlPGhB07ZiONFUlZmUcGyElpvznnchTWL0RxwfsvGzBdSsE4d4O GvQI+n+RGasEZbcvTSeNu+4PCkVQX0LvUf5a1f35+LtP0KtXc6iXkKPjOZ4bzByzD3IcVMIgwtQq4 zeNiaXbfpl+mZIGQxwe/VQ==; Received: from [87.69.77.57] (port=2557 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 1o7huG-00049H-B7; Sat, 02 Jul 2022 14:31:48 -0400 Date: Sat, 02 Jul 2022 21:31:35 +0300 Message-Id: <83bku7bc3c.fsf@gnu.org> From: Eli Zaretskii To: Stefan Monnier In-Reply-To: (message from Stefan Monnier on Sat, 02 Jul 2022 14:00:41 -0400) Subject: Re: bug#56347: Optimize/simplify STRING_SET_MULTIBYTE References: <83pmioca3h.fsf@gnu.org> <83letbbhzx.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 56347 Cc: 56347@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Stefan Monnier > Cc: 56347@debbugs.gnu.org > Date: Sat, 02 Jul 2022 14:00:41 -0400 > > >> No, I want to reduce the scope of semantics of the macro, e.g. so it can > >> be implemented as a function rather than a macro and so it doesn't > >> magically substitute empty_multibyte_string into a variable that held > >> something else. > > But the effect is that you disallow calling STRING_SET_MULTIBYTE on an > > empty string, isn't it? > > Yes. In my book, STRING_SET_*IBYTE should basically not exist: a string > is created as unibyte or multibyte and never changes after that. That's require a much larger change, I think. It is not enough just to add an assertion in one place, because that'd just cause maintenance headaches for no real gain. And I'm not even sure everyone will agree with such a radical change. It should be discussed first. > And indeed because we only have a single copy of the two possible empty > strings, they can't be changed between unibyte<->multibyte I can create an empty string without those singletons any time. From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 02 14:37:29 2022 Received: (at 56347) by debbugs.gnu.org; 2 Jul 2022 18:37:29 +0000 Received: from localhost ([127.0.0.1]:42852 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o7hzl-0000qF-5D for submit@debbugs.gnu.org; Sat, 02 Jul 2022 14:37:29 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:58644) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o7hzi-0000q3-Ua for 56347@debbugs.gnu.org; Sat, 02 Jul 2022 14:37:27 -0400 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 723B1100164; Sat, 2 Jul 2022 14:37:21 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 0E6A8100121; Sat, 2 Jul 2022 14:37:20 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1656787040; bh=0fQUsY4wROiBu7XEvJqhZQPNtwHuzsC1G/RveC1557I=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=LQZUS7vX6YUtbLBQ10XI9QflMUjDM/ifEJUKILu5vb3hd+rBfbsbOQlmEYTcM4Klx zH4QqnlSp1g+JDBmsyznURo/bwz8f9NMpMdcmxmZx4oU7haY0PCcXAeteKJChzeNhw ISRU+6k8IZIdNE6vDTnfTn1wffheSz7HgQA7QdQ6tZZ1ByaJOHercDeYj12fHOufKR F/CwLciJVbL2lY62DKs3z85IzAZLrHWQAYhhFTV1b9k3LaDJIKmi+DykK78jvRFsU/ JynSe2ZewuGyqfkFLOyARvQLM0kUcdAhk11v0sbOOWPhfPRgCBtFdUfI4ZLvEERRp6 DliZ+PjWNXSsA== Received: from alfajor (unknown [45.72.196.165]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id D767712043F; Sat, 2 Jul 2022 14:37:19 -0400 (EDT) From: Stefan Monnier To: Eli Zaretskii Subject: Re: bug#56347: Optimize/simplify STRING_SET_MULTIBYTE Message-ID: References: <83pmioca3h.fsf@gnu.org> <83letbbhzx.fsf@gnu.org> <83bku7bc3c.fsf@gnu.org> Date: Sat, 02 Jul 2022 14:37:18 -0400 In-Reply-To: <83bku7bc3c.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 02 Jul 2022 21:31:35 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.044 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain T_SCC_BODY_TEXT_LINE -0.01 - X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 56347 Cc: 56347@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) >> Yes. In my book, STRING_SET_*IBYTE should basically not exist: a string >> is created as unibyte or multibyte and never changes after that. > > That's require a much larger change, I think. It is not enough just > to add an assertion in one place, because that'd just cause > maintenance headaches for no real gain. `grep STRING_SET_MULTIBYTE` suggests it's not nearly as hard you think. The only other use is in `aset`. >> And indeed because we only have a single copy of the two possible empty >> strings, they can't be changed between unibyte<->multibyte > I can create an empty string without those singletons any time. My experience is that it takes a fair bit of work to do so. Stefan From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 02 14:45:44 2022 Received: (at 56347) by debbugs.gnu.org; 2 Jul 2022 18:45:44 +0000 Received: from localhost ([127.0.0.1]:42857 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o7i7j-00012C-VF for submit@debbugs.gnu.org; Sat, 02 Jul 2022 14:45:44 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45694) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o7i7h-00011z-ST for 56347@debbugs.gnu.org; Sat, 02 Jul 2022 14:45:42 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:52176) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o7i7c-0006bw-JA; Sat, 02 Jul 2022 14:45:36 -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=7C7zUwa7DyPgmkXYDqlhOldc/1xoRUiMNGYzmd+f/7g=; b=cFEbceXUnG5i BZ0iJzEX54LbfEZq1/8tza8zn/ib78F8CbhHuksXkiWKtQdZ4ksYoJQJ3KBZQ8Udg3hyxX52A8v4l BsKjurxOqymZfFZcO4ark/ZMb9h4F8hTRv7Btcbiq8DjCnHyQbIBMGfYyP01gkXoaQ+cLn0NRkzhh wGm0qCRUmui3g2sXTQKULdh8yX2wQHgALD+2SlYvSoH+SHxbSAT9ehW8P69rjF1H3hOZLLvFsvg1E s4WvfyMjSE2D+an/91qx210RePDFuEl4jvqQC+4a5cxmyOQSDe0Y32aXvbuBsqte7o7LxG08vzvvg AoGDOp5eG1xvqZsgjqYUrw==; Received: from [87.69.77.57] (port=3403 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 1o7i7c-00064N-2l; Sat, 02 Jul 2022 14:45:36 -0400 Date: Sat, 02 Jul 2022 21:45:21 +0300 Message-Id: <835ykfbbge.fsf@gnu.org> From: Eli Zaretskii To: Stefan Monnier In-Reply-To: (message from Stefan Monnier on Sat, 02 Jul 2022 14:37:18 -0400) Subject: Re: bug#56347: Optimize/simplify STRING_SET_MULTIBYTE References: <83pmioca3h.fsf@gnu.org> <83letbbhzx.fsf@gnu.org> <83bku7bc3c.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 56347 Cc: 56347@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Stefan Monnier > Cc: 56347@debbugs.gnu.org > Date: Sat, 02 Jul 2022 14:37:18 -0400 > > >> Yes. In my book, STRING_SET_*IBYTE should basically not exist: a string > >> is created as unibyte or multibyte and never changes after that. > > > > That's require a much larger change, I think. It is not enough just > > to add an assertion in one place, because that'd just cause > > maintenance headaches for no real gain. > > `grep STRING_SET_MULTIBYTE` suggests it's not nearly as hard you think. > > The only other use is in `aset`. That's not what I meant. If you want to disallow changing the representation of strings, STRING_SET_MULTIBYTE is just the tip of the iceberg. > >> And indeed because we only have a single copy of the two possible empty > >> strings, they can't be changed between unibyte<->multibyte > > I can create an empty string without those singletons any time. > > My experience is that it takes a fair bit of work to do so. I don't see how that matters here, sorry. From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 09 13:46:01 2022 Received: (at control) by debbugs.gnu.org; 9 Jul 2022 17:46:01 +0000 Received: from localhost ([127.0.0.1]:35864 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oAEWn-0006Qf-5L for submit@debbugs.gnu.org; Sat, 09 Jul 2022 13:46:01 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:63338) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oAEWl-0006QU-QP for control@debbugs.gnu.org; Sat, 09 Jul 2022 13:46:00 -0400 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 51C468007C; Sat, 9 Jul 2022 13:45:54 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 36E9B80355; Sat, 9 Jul 2022 13:45:53 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1657388753; bh=6zmayYCdMcl9EvrshHlxHfX+U+AYTwq1Lc5nGNY9lGM=; h=From:To:Subject:In-Reply-To:References:Date:From; b=E3HGsv5HB/z73FNUihaJrh6S4of6kAWuVZuJxAQvK97dcv9OWXXpY3pbByTic7hOd zOazj7PboY7pfH01TM4Irc3MMHscDJMbAOljKw0U/Lcb28/Lckm4Se+7pYFi2x4mRP FoQcBFvgK+UAxAkxCMoXhpAkZz9pw3M4e8aw0ElWFmmHI5AECgYORhEfcOK1VK+v8R JlgQ2qOfVgc1FtC/vU0sQ2ZiVzFeqTOr9lOnC91ERFfs1FWlYztFMFRpkLN0bG+fw/ BdCcQ1nAcSfkLDgJJKUolgcu20pngphSv4NC0cBIr50lhEqKvcvyzNgiSxLBpzUcWD vJtAaQQEYK3bg== Received: from pastel (unknown [45.72.196.165]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 03BB81201CA; Sat, 9 Jul 2022 13:45:52 -0400 (EDT) From: Stefan Monnier To: control@debbugs.gnu.org Subject: Re: bug#56347: Acknowledgement (Optimize/simplify STRING_SET_MULTIBYTE) In-Reply-To: (GNU bug Tracking System's message of "Fri, 01 Jul 2022 23:33:02 +0000") Message-ID: References: Date: Sat, 09 Jul 2022 13:45:51 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.055 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain T_SCC_BODY_TEXT_LINE -0.01 - X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) close 56347 From unknown Thu Aug 14 22:19:57 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 07 Aug 2022 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator