aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Monnier2022-07-09 12:53:34 -0400
committerStefan Monnier2022-07-09 12:53:34 -0400
commitad011fd3accd97f5ab96dd7459ee8ef9f6ab4090 (patch)
tree53f7d96b6232158c7eaeab028dc017ac1dc61a71 /src
parent16e79eb75f0d55bc24442f0faf11cd0a4ca8f62c (diff)
downloademacs-ad011fd3accd97f5ab96dd7459ee8ef9f6ab4090.tar.gz
emacs-ad011fd3accd97f5ab96dd7459ee8ef9f6ab4090.zip
Make STRING_SET_MULTIBYTE an inline function
* src/lisp.h (STRING_SET_MULTIBYTE): Make it into a function. * src/composite.c (Fcomposition_get_gstring): Prefer `make_multibyte_string` over Fconcat+STRING_SET_MULTIBYTE.
Diffstat (limited to 'src')
-rw-r--r--src/composite.c10
-rw-r--r--src/lisp.h14
2 files changed, 13 insertions, 11 deletions
diff --git a/src/composite.c b/src/composite.c
index 4d69702171f..552214ae848 100644
--- a/src/composite.c
+++ b/src/composite.c
@@ -1871,7 +1871,8 @@ should be ignored. */)
1871 else 1871 else
1872 { 1872 {
1873 CHECK_STRING (string); 1873 CHECK_STRING (string);
1874 validate_subarray (string, from, to, SCHARS (string), &frompos, &topos); 1874 ptrdiff_t chars = SCHARS (string);
1875 validate_subarray (string, from, to, chars, &frompos, &topos);
1875 if (! STRING_MULTIBYTE (string)) 1876 if (! STRING_MULTIBYTE (string))
1876 { 1877 {
1877 ptrdiff_t i; 1878 ptrdiff_t i;
@@ -1881,9 +1882,10 @@ should be ignored. */)
1881 error ("Attempt to shape unibyte text"); 1882 error ("Attempt to shape unibyte text");
1882 /* STRING is a pure-ASCII string, so we can convert it (or, 1883 /* STRING is a pure-ASCII string, so we can convert it (or,
1883 rather, its copy) to multibyte and use that thereafter. */ 1884 rather, its copy) to multibyte and use that thereafter. */
1884 Lisp_Object string_copy = Fconcat (1, &string); 1885 /* FIXME: Not clear why we need to do that: AFAICT the rest of
1885 STRING_SET_MULTIBYTE (string_copy); 1886 the code should work on an ASCII-only unibyte string just
1886 string = string_copy; 1887 as well (bug#56347). */
1888 string = make_multibyte_string (SDATA (string), chars, chars);
1887 } 1889 }
1888 frombyte = string_char_to_byte (string, frompos); 1890 frombyte = string_char_to_byte (string, frompos);
1889 } 1891 }
diff --git a/src/lisp.h b/src/lisp.h
index 5ffc2bb0386..dc496cc1658 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -1640,13 +1640,13 @@ STRING_MULTIBYTE (Lisp_Object str)
1640 1640
1641/* Mark STR as a multibyte string. Assure that STR contains only 1641/* Mark STR as a multibyte string. Assure that STR contains only
1642 ASCII characters in advance. */ 1642 ASCII characters in advance. */
1643#define STRING_SET_MULTIBYTE(STR) \ 1643INLINE void
1644 do { \ 1644STRING_SET_MULTIBYTE (Lisp_Object str)
1645 if (XSTRING (STR)->u.s.size == 0) \ 1645{
1646 (STR) = empty_multibyte_string; \ 1646 /* The 0-length strings are unique&shared so we can't modify them. */
1647 else \ 1647 eassert (XSTRING (str)->u.s.size > 0);
1648 XSTRING (STR)->u.s.size_byte = XSTRING (STR)->u.s.size; \ 1648 XSTRING (str)->u.s.size_byte = XSTRING (str)->u.s.size;
1649 } while (false) 1649}
1650 1650
1651/* Convenience functions for dealing with Lisp strings. */ 1651/* Convenience functions for dealing with Lisp strings. */
1652 1652