]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix a recent change in coding.c
authorEli Zaretskii <eliz@gnu.org>
Sun, 25 Aug 2019 08:08:11 +0000 (11:08 +0300)
committerEli Zaretskii <eliz@gnu.org>
Sun, 25 Aug 2019 08:08:11 +0000 (11:08 +0300)
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
src/coding.h

index 1c6475828dfd764bb1387e4c974d6d10eac19087..c0408fbce480eabac3c00ee68858ba781cf3f652 100644 (file)
@@ -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.  */
 
index 70690d42d30229323786b07eea9756be85e1a868..8efddbf55c40a907477ba036bcb19e94bac79652 100644 (file)
@@ -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);