diff options
| author | Mattias EngdegÄrd | 2024-03-31 15:00:00 +0200 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2024-04-01 10:41:46 +0200 |
| commit | 734bd005aa0fa955cf1a46d3a60a4d6ef5e7e3d1 (patch) | |
| tree | 28e48c30e5916247065e8e66d9a80d9991ec1c2b /src/lisp.h | |
| parent | f178a6d8006f1e8afe06bb71d0a413622d73f131 (diff) | |
| download | emacs-734bd005aa0fa955cf1a46d3a60a4d6ef5e7e3d1.tar.gz emacs-734bd005aa0fa955cf1a46d3a60a4d6ef5e7e3d1.zip | |
Faster JSON parsing
Speed up JSON parsing substantially by only UTF-8-parsing string
literals and only exactly once. Previously, json-parse-string always
first parsed the entire input and copied it to a new string, and then
validated each string literal twice.
We no longer create an extra new string when interning an alist key,
nor do we garble plist keys with Unicode characters.
* src/lread.c (intern_c_multibyte): New.
* src/json.c (json_encode): Remove.
(utf8_error): New.
(json_parse_string): Faster and more careful UTF-8 decoding.
Create and return a new multibyte string or symbol without extra
decoding. All callers adapted.
(Fjson_parse_string): Skip expensive input pre-decoding.
* test/src/json-tests.el (json-parse-string/object-unicode-keys)
(json-parse-string/short): New.
(json-parse-string/string, json-parse-string/invalid-unicode):
Adapt tests.
* etc/NEWS: Mentioned change in errors.
Diffstat (limited to 'src/lisp.h')
| -rw-r--r-- | src/lisp.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/lisp.h b/src/lisp.h index 43a29489a25..3cb4361e75e 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -4744,6 +4744,8 @@ extern ptrdiff_t evxprintf (char **, ptrdiff_t *, char *, ptrdiff_t, | |||
| 4744 | extern Lisp_Object intern_1 (const char *, ptrdiff_t); | 4744 | extern Lisp_Object intern_1 (const char *, ptrdiff_t); |
| 4745 | extern Lisp_Object intern_c_string_1 (const char *, ptrdiff_t); | 4745 | extern Lisp_Object intern_c_string_1 (const char *, ptrdiff_t); |
| 4746 | extern Lisp_Object intern_driver (Lisp_Object, Lisp_Object, Lisp_Object); | 4746 | extern Lisp_Object intern_driver (Lisp_Object, Lisp_Object, Lisp_Object); |
| 4747 | extern Lisp_Object intern_c_multibyte (const char *str, | ||
| 4748 | ptrdiff_t nchars, ptrdiff_t nbytes); | ||
| 4747 | extern void init_symbol (Lisp_Object, Lisp_Object); | 4749 | extern void init_symbol (Lisp_Object, Lisp_Object); |
| 4748 | extern Lisp_Object oblookup (Lisp_Object, const char *, ptrdiff_t, ptrdiff_t); | 4750 | extern Lisp_Object oblookup (Lisp_Object, const char *, ptrdiff_t, ptrdiff_t); |
| 4749 | INLINE void | 4751 | INLINE void |