[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#20154: 25.0.50; json-encode-string is too slow for large strings
From: |
Eli Zaretskii |
Subject: |
bug#20154: 25.0.50; json-encode-string is too slow for large strings |
Date: |
Sat, 21 Mar 2015 10:07:22 +0200 |
> Date: Sat, 21 Mar 2015 00:26:03 +0200
> From: Dmitry Gutov <dgutov@yandex.ru>
> CC: 20154@debbugs.gnu.org
>
> As per your comment, this seems to be the best we can do for long
> strings, without diving into C:
>
> (defun json-encode-string-1 (string)
> "Return a JSON representation of STRING."
> (with-temp-buffer
> (insert string)
> (goto-char (point-min))
> ;; Skip over ASCIIish printable characters.
> (while (re-search-forward "\\([\"\\/\b\f\n\r\t]\\)\\|[^ -~]" nil t)
> (replace-match
> (if (match-beginning 1)
> ;; Special JSON character (\n, \r, etc.).
> (format "\\%c" (char-after (match-beginning 0)))
Do you really need 'format' here? Why not
(concat "\\" (char-to-string (char-after (match-beginning 0))))
instead?
Or even simply insert these two parts at the match point, after
deleting the match.
- bug#20154: 25.0.50; json-encode-string is too slow for large strings, (continued)
- bug#20154: 25.0.50; json-encode-string is too slow for large strings, Eli Zaretskii, 2015/03/21
- bug#20154: 25.0.50; json-encode-string is too slow for large strings, Dmitry Gutov, 2015/03/21
- bug#20154: 25.0.50; json-encode-string is too slow for large strings, Eli Zaretskii, 2015/03/22
- bug#20154: 25.0.50; json-encode-string is too slow for large strings, Dmitry Gutov, 2015/03/22
- bug#20154: 25.0.50; json-encode-string is too slow for large strings, Dmitry Gutov, 2015/03/22
- bug#20154: 25.0.50; json-encode-string is too slow for large strings, Eli Zaretskii, 2015/03/22
- bug#20154: 25.0.50; json-encode-string is too slow for large strings, Dmitry Gutov, 2015/03/22
- bug#20154: 25.0.50; json-encode-string is too slow for large strings, Drew Adams, 2015/03/21
- bug#20154: 25.0.50; json-encode-string is too slow for large strings, Dmitry Gutov, 2015/03/21
- bug#20154: 25.0.50; json-encode-string is too slow for large strings, Dmitry Gutov, 2015/03/20
- bug#20154: 25.0.50; json-encode-string is too slow for large strings,
Eli Zaretskii <=
- bug#20154: 25.0.50; json-encode-string is too slow for large strings, Dmitry Gutov, 2015/03/21
- bug#20154: 25.0.50; json-encode-string is too slow for large strings, Ivan Shmakov, 2015/03/21
- bug#20154: 25.0.50; json-encode-string is too slow for large strings, Dmitry Gutov, 2015/03/21
- bug#20154: 25.0.50; json-encode-string is too slow for large strings, Dmitry Gutov, 2015/03/22
- bug#20154: 25.0.50; json-encode-string is too slow for large strings, Ivan Shmakov, 2015/03/22
- bug#20154: 25.0.50; json-encode-string is too slow for large strings, Dmitry Gutov, 2015/03/22
- bug#20154: 25.0.50; json-encode-string is too slow for large strings, Eli Zaretskii, 2015/03/22
- bug#20154: 25.0.50; json-encode-string is too slow for large strings, Ivan Shmakov, 2015/03/22
- bug#20154: 25.0.50; json-encode-string is too slow for large strings, Eli Zaretskii, 2015/03/22
- bug#20154: 25.0.50; json-encode-string is too slow for large strings, Glenn Morris, 2015/03/22