]> git.eshelyaron.com Git - emacs.git/commit
New JSON encoder (bug#70007)
authorMattias EngdegÄrd <mattiase@acm.org>
Tue, 26 Mar 2024 15:44:09 +0000 (16:44 +0100)
committerEshel Yaron <me@eshelyaron.com>
Sat, 30 Mar 2024 19:37:10 +0000 (20:37 +0100)
commite57f50caa9deeba61637546d8ab57fca7bda020f
tree87ad2892b0285cce700df2e9dc8d70c2efbb40c3
parentb5a0fda08bad61c3aa89084df98e7ca4deccad68
New JSON encoder (bug#70007)

It is in general at least 2x faster than the old encoder and does not
depend on any external library.  Using our own code also gives us
control over translation details: for example, we now have full
bignum support and tighter float formatting.

* src/json.c (json_delete, json_initialized, init_json_functions)
(json_malloc, json_free, init_json, json_out_of_memory)
(json_releae_object, check_string_without_embedded_nulls, json_check)
(json_check_utf8, lisp_to_json_nonscalar_1, lisp_to_json_nonscalar)
(lisp_to_json, json_available_p, ensure_json_available, json_insert)
(json_handle_nonlocal_exit, json_insert_callback):
Remove.  Remaining uses updated.
* src/json.c (json_out_t, symset_t, struct symset_tbl)
(symset_size, make_symset_table, push_symset, pop_symset)
(cleanup_symset_tables, symset_hash, symset_expand, symset_add)
(json_out_grow_buf, cleanup_json_out, json_make_room, JSON_OUT_STR)
(json_out_str, json_out_byte, json_out_fixnum, string_not_unicode)
(json_plain_char, json_out_string, json_out_nest, json_out_unnest)
(json_out_object_cons, json_out_object_hash), json_out_array)
(json_out_float, json_out_bignum, json_out_something)
(json_out_to_string, json_serialize): New.
(Fjson_serialize, Fjson_insert):
New JSON encoder implementation.
* test/src/json-tests.el (json-serialize/object-with-duplicate-keys)
(json-serialize/string): Update tests.

(cherry picked from commit 890edfd2bb8fd79730919972cc82811b73c7f572)
src/emacs.c
src/json.c
src/lisp.h
src/print.c
test/src/json-tests.el