summaryrefslogtreecommitdiff
path: root/src/coding.c
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2019-08-25 11:08:11 +0300
committerEli Zaretskii <eliz@gnu.org>2019-08-25 11:08:11 +0300
commit543ae99fe8cf21a00087ace878dbec909546476b (patch)
treea7812187d3f02c8f6858ea2e257411da16465cc4 /src/coding.c
parent26703b98f93ff6e0819e43b872bfe63f8753dfcb (diff)
downloademacs-543ae99fe8cf21a00087ace878dbec909546476b.tar.gz
emacs-543ae99fe8cf21a00087ace878dbec909546476b.tar.bz2
emacs-543ae99fe8cf21a00087ace878dbec909546476b.zip
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.
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/coding.c b/src/coding.c
index 1c6475828df..c0408fbce48 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. */