• Mattias Engdegård's avatar
    Faster JSON parsing · 734bd005
    Mattias Engdegård authored
    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.
    734bd005