]> git.eshelyaron.com Git - emacs.git/commitdiff
Use cheaper string constructors
authorMattias EngdegÄrd <mattiase@acm.org>
Tue, 9 Jul 2024 08:01:03 +0000 (10:01 +0200)
committerEshel Yaron <me@eshelyaron.com>
Tue, 9 Jul 2024 17:51:16 +0000 (19:51 +0200)
* 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`.

(cherry picked from commit 7e358aa706f9dbfce24304e8a05904538615537f)

src/coding.c
src/fileio.c
src/gnutls.c
src/lread.c

index b48164efc69d4f99e0d6bbbf18c42b76cdf8e432..e42b6b6e72033dec0cbeb935ef2859e32bfc23f4 100644 (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;
index 7afe3e757370a085b38b95a4981fd87aadbc62a6..fa280f2db0027a374978f93f2654a7f27e988071 100644 (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;
index 3ff7f21d5a5028236e22178f3b67604a251c3563..334d1d47eb6fd45eedcf884a21a67bed0bc35d04 100644 (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);
 
index c3b0e8a3ef5ddfe543ca79dcc5b6a8b330829b60..c1f309866c859be95db7e11333497a9696ea354d 100644 (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);
        }