mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-06-14 12:31:25 +00:00
Faster JSON string serialisation (bug#80529)
* src/json.c (json_out_string): Optimise for runs of non-special ASCII chars. This seems to be a a substantial performance gain for long strings but a smaller regression for short strings (up to 6 chars or thereabouts, depending on cpu, compiler, and/or C library). Still likely worth it. Suggested by Pavel <cyberkm@gmail.com>.
This commit is contained in:
parent
72a1bda759
commit
dfa4a0e5a2
1 changed files with 9 additions and 5 deletions
14
src/json.c
14
src/json.c
|
|
@ -332,13 +332,17 @@ json_out_string (json_out_t *jo, Lisp_Object str, int skip)
|
|||
p += skip;
|
||||
while (p < end)
|
||||
{
|
||||
unsigned char c = *p;
|
||||
if (json_plain_char[c])
|
||||
unsigned char *run = p;
|
||||
while (p < end && json_plain_char[*p])
|
||||
p++;
|
||||
if (p > run)
|
||||
{
|
||||
json_out_byte (jo, c);
|
||||
p++;
|
||||
json_out_str (jo, (const char *)run, p - run);
|
||||
continue;
|
||||
}
|
||||
else if (c > 0x7f)
|
||||
|
||||
unsigned char c = *p;
|
||||
if (c > 0x7f)
|
||||
{
|
||||
if (STRING_MULTIBYTE (str))
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue