unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 56347@debbugs.gnu.org
Subject: bug#56347: Optimize/simplify STRING_SET_MULTIBYTE
Date: Fri, 01 Jul 2022 19:32:05 -0400	[thread overview]
Message-ID: <jwv1qv4wgsq.fsf@iro.umontreal.ca> (raw)

[-- Attachment #1: Type: text/plain, Size: 689 bytes --]

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'


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: set-multibyte.patch --]
[-- Type: text/patch, Size: 1513 bytes --]

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.  */

             reply	other threads:[~2022-07-01 23:32 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-01 23:32 Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2022-07-02  6:17 ` bug#56347: Optimize/simplify STRING_SET_MULTIBYTE Eli Zaretskii
2022-07-02 16:12   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-02 16:24     ` Eli Zaretskii
2022-07-02 18:00       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-02 18:31         ` Eli Zaretskii
2022-07-02 18:37           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-02 18:45             ` Eli Zaretskii
2022-07-02 16:49   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-02 17:06     ` Eli Zaretskii
2022-07-02 17:57       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwv1qv4wgsq.fsf@iro.umontreal.ca \
    --to=bug-gnu-emacs@gnu.org \
    --cc=56347@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).