]> git.eshelyaron.com Git - emacs.git/commit
Faster JSON parsing
authorMattias EngdegÄrd <mattiase@acm.org>
Sun, 31 Mar 2024 13:00:00 +0000 (15:00 +0200)
committerEshel Yaron <me@eshelyaron.com>
Tue, 2 Apr 2024 13:24:56 +0000 (15:24 +0200)
commitdbd2619ccd9e4cea8677b9f053a5bc0ed0444315
treec59b7828bb121b70b446bd1ee67690de1db44bd3
parentbeb200a0e2e9e72eea741b8a11b2663424b88c68
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.

(cherry picked from commit 734bd005aa0fa955cf1a46d3a60a4d6ef5e7e3d1)
etc/NEWS
src/json.c
src/lisp.h
src/lread.c
test/src/json-tests.el