emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 543ae99: Fix a recent change in coding.c


From: Eli Zaretskii
Subject: [Emacs-diffs] master 543ae99: Fix a recent change in coding.c
Date: Sun, 25 Aug 2019 04:09:38 -0400 (EDT)

branch: master
commit 543ae99fe8cf21a00087ace878dbec909546476b
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Fix a recent change in coding.c
    
    This partially reverts the changes in "extern function cleanup".
    * src/coding.c (encode_string_utf_8, decode_string_utf_8): Now
    extern again.  They should NOT be static, as they are intended
    to be used by the likes of json.c, where we need
    highly-optimized code for processing UTF-8 strings.  E.g.,
    decode_string_utf_8 beats make_string_from_utf8 by a factor of
    2 to 5 in a large number of scenarios.
---
 src/coding.c | 17 ++++++++++-------
 src/coding.h |  4 ++++
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/src/coding.c b/src/coding.c
index 1c64758..c0408fb 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -9516,10 +9516,6 @@ code_convert_string_norecord (Lisp_Object string, 
Lisp_Object coding_system,
 }
 
 
-/* #define ENABLE_UTF_8_CONVERTER_TEST */
-
-#ifdef ENABLE_UTF_8_CONVERTER_TEST
-
 /* Return the gap address of BUFFER.  If the gap size is less than
    NBYTES, enlarge the gap in advance.  */
 
@@ -9622,7 +9618,7 @@ get_char_bytes (int c, int *len)
    If the two arguments are Qnil, return Qnil if STRING has a
    non-Unicode character.  */
 
-static Lisp_Object
+Lisp_Object
 encode_string_utf_8 (Lisp_Object string, Lisp_Object buffer,
                     bool nocopy, Lisp_Object handle_8_bit,
                     Lisp_Object handle_over_uni)
@@ -9846,7 +9842,10 @@ encode_string_utf_8 (Lisp_Object string, Lisp_Object 
buffer,
    If BUFFER is Qnil, return a multibyte string from the decoded result.
    As a special case, return STRING itself in the following cases:
    1. STRING contains only ASCII characters.
-   2. NOCOPY, and STRING contains only valid UTF-8 sequences.
+   2. NOCOPY is true, and STRING contains only valid UTF-8 sequences.
+
+   For maximum speed, always specify NOCOPY true when STRING is
+   guaranteed to contain only valid UTF-8 sequences.
 
    HANDLE-8-BIT and HANDLE-OVER-UNI specify how to handle a invalid
    byte sequence.  The former is for an 1-byte invalid sequence that
@@ -9877,7 +9876,7 @@ encode_string_utf_8 (Lisp_Object string, Lisp_Object 
buffer,
    If the two arguments are Qnil, return Qnil if STRING has an invalid
    sequence.  */
 
-static Lisp_Object
+Lisp_Object
 decode_string_utf_8 (Lisp_Object string, Lisp_Object buffer,
                     bool nocopy, Lisp_Object handle_8_bit,
                     Lisp_Object handle_over_uni)
@@ -10115,6 +10114,10 @@ decode_string_utf_8 (Lisp_Object string, Lisp_Object 
buffer,
   return val;
 }
 
+/* #define ENABLE_UTF_8_CONVERTER_TEST */
+
+#ifdef ENABLE_UTF_8_CONVERTER_TEST
+
 /* These functions are useful for testing and benchmarking
    encode_string_utf_8 and decode_string_utf_8.  */
 
diff --git a/src/coding.h b/src/coding.h
index 70690d4..8efddbf 100644
--- a/src/coding.h
+++ b/src/coding.h
@@ -689,6 +689,10 @@ extern Lisp_Object code_convert_string (Lisp_Object, 
Lisp_Object,
                                         Lisp_Object, bool, bool, bool);
 extern Lisp_Object code_convert_string_norecord (Lisp_Object, Lisp_Object,
                                                  bool);
+extern Lisp_Object encode_string_utf_8 (Lisp_Object, Lisp_Object, bool,
+                                       Lisp_Object, Lisp_Object);
+extern Lisp_Object decode_string_utf_8 (Lisp_Object, Lisp_Object, bool,
+                                       Lisp_Object, Lisp_Object);
 extern Lisp_Object encode_file_name (Lisp_Object);
 extern Lisp_Object decode_file_name (Lisp_Object);
 extern Lisp_Object raw_text_coding_system (Lisp_Object);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]