Use cheaper string constructors

* src/coding.c (make_string_from_utf8):
* src/fileio.c (file_name_directory):
* src/lread.c (Fintern):
* src/gnutls.c (Fgnutls_format_certificate):
Use `make_multibyte_string` and `make_unibyte_string` instead of
more expensive `make_specified_string` and `make_string_from_bytes`.
This commit is contained in:
Mattias Engdegård 2024-07-09 10:01:03 +02:00
parent acfc3884bf
commit 7e358aa706
4 changed files with 5 additions and 6 deletions

View file

@ -6365,7 +6365,7 @@ make_string_from_utf8 (const char *text, ptrdiff_t nbytes)
/* If TEXT is a valid UTF-8 string, we can convert it to a Lisp
string directly. Otherwise, we need to decode it. */
if (chars == nbytes || bytes == nbytes)
return make_specified_string (text, chars, nbytes, true);
return make_multibyte_string (text, chars, nbytes);
else
{
struct coding_system coding;

View file

@ -523,7 +523,7 @@ file_name_directory (Lisp_Object filename)
else
{
dostounix_filename (beg);
tem_fn = make_specified_string (beg, -1, p - beg, 0);
tem_fn = make_unibyte_string (beg, p - beg);
}
SAFE_FREE ();
return tem_fn;

View file

@ -1646,8 +1646,7 @@ string representation. */)
emacs_gnutls_strerror (err));
}
Lisp_Object result = make_string_from_bytes ((char *) out.data, out.size,
out.size);
Lisp_Object result = make_unibyte_string ((char *) out.data, out.size);
gnutls_free (out.data);
gnutls_x509_crt_deinit (crt);

View file

@ -5025,8 +5025,8 @@ it defaults to the value of `obarray'. */)
{
if (longhand)
{
tem = intern_driver (make_specified_string (longhand, longhand_chars,
longhand_bytes, true),
tem = intern_driver (make_multibyte_string (longhand, longhand_chars,
longhand_bytes),
obarray, tem);
xfree (longhand);
}