]> git.eshelyaron.com Git - emacs.git/commit
Improve 'json-insert' so it doesn't cons a string from JSON
authorEli Zaretskii <eliz@gnu.org>
Sat, 13 Oct 2018 07:13:10 +0000 (10:13 +0300)
committerEli Zaretskii <eliz@gnu.org>
Sat, 13 Oct 2018 07:13:10 +0000 (10:13 +0300)
commit95f69e7db235ca450a17c5a24680b742dfdf9aae
treec186902d218c8fca88d3379f84f26738cdfc9fc5
parent6cf4dfe472650b3396d2f2592726621a43896de3
Improve 'json-insert' so it doesn't cons a string from JSON

* src/json.c (struct json_buffer_and_size): New member
inserted_bytes.
(json_insert): Instead of creating a string and inserting it
into the current buffer, copy the unibyte text into the gap.
(struct json_insert_data): New member inserted_bytes.
(json_insert_callback): Update commentary.  Pass the
inserted_bytes value to json_insert and on its return copy the
updated value back into DATA.
(Fjson_insert): Decode the unibyte text inserted into the gap.
Call before-change-functions and after-change-functions only
once, before and after processing the insertion of the entire
JSON representation.

* test/src/json-tests.el (json-insert/throw): Adapt to the
modified implementation of json-insert: it no longer calls the
modification hooks once for each inserted chunk of JSON
representation.
src/json.c
test/src/json-tests.el