From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ivan Shmakov Newsgroups: gmane.emacs.bugs Subject: bug#20154: 25.0.50; json-encode-string is too slow for large strings Date: Sun, 22 Mar 2015 16:15:48 +0000 Message-ID: <87384xvwi3.fsf@violet.siamics.net> References: <86twxf68zk.fsf@yandex.ru> <83384zwxdx.fsf@gnu.org> <550C3218.4000903@yandex.ru> <831tkjww0y.fsf@gnu.org> <550C3AB9.7020403@yandex.ru> <83wq2bveq6.fsf@gnu.org> <550C491A.6000909@yandex.ru> <83siczvcss.fsf@gnu.org> <550C504A.10708@yandex.ru> <83r3sjva0q.fsf@gnu.org> <550C6A06.6040203@yandex.ru> <83fv8zv0b1.fsf@gnu.org> <550C9E7B.4060907@yandex.ru> <837fuavkn9.fsf@gnu.org> <550DDE25.1090000@yandex.ru> <550E0097.9000500@yandex.ru> <550ED713.2010201@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1427040991 5109 80.91.229.3 (22 Mar 2015 16:16:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 22 Mar 2015 16:16:31 +0000 (UTC) To: 20154@debbugs.gnu.org, Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Mar 22 17:16:17 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YZiXt-0001vg-VE for geb-bug-gnu-emacs@m.gmane.org; Sun, 22 Mar 2015 17:16:14 +0100 Original-Received: from localhost ([::1]:51612 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YZiXs-0003xC-Pt for geb-bug-gnu-emacs@m.gmane.org; Sun, 22 Mar 2015 12:16:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33394) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YZiXo-0003ww-KG for bug-gnu-emacs@gnu.org; Sun, 22 Mar 2015 12:16:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YZiXk-0004d9-Gx for bug-gnu-emacs@gnu.org; Sun, 22 Mar 2015 12:16:08 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:42799) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YZiXi-0004cz-IY for bug-gnu-emacs@gnu.org; Sun, 22 Mar 2015 12:16:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1YZiXi-0003Fu-9b for bug-gnu-emacs@gnu.org; Sun, 22 Mar 2015 12:16:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ivan Shmakov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 22 Mar 2015 16:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20154 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 20154-submit@debbugs.gnu.org id=B20154.142704096112505 (code B ref 20154); Sun, 22 Mar 2015 16:16:02 +0000 Original-Received: (at 20154) by debbugs.gnu.org; 22 Mar 2015 16:16:01 +0000 Original-Received: from localhost ([127.0.0.1]:60808 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YZiXg-0003Fc-KU for submit@debbugs.gnu.org; Sun, 22 Mar 2015 12:16:00 -0400 Original-Received: from fely.am-1.org ([78.47.74.50]:60970) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YZiXe-0003FR-Aq for 20154@debbugs.gnu.org; Sun, 22 Mar 2015 12:15:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=siamics.net; s=a2013295; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:Sender:References:Subject:To:From; bh=9dYFOJ4BZ/9VcRBeEPSfwyUgqKep/LuIURX09JLu3+4=; b=LHwmeNLPiWRfKCdGNm+tBPyangtNAVCnfO4xJsEjkHqyWgCPkgY04nAuEJ7fv6iYYpc3bAGquKas9LxJpxkg/1GyTnnr59sF/Z1gqgmFZgbrK6J5usFsCYmX4gXcWK4x/m0R1OickrZ5vfuCdg4ezuPdbeRLxWSOo5rX7Xu7ZYc=; Original-Received: from [2a02:2560:6d4:26ca::1:1d] (helo=violet.siamics.net) by fely.am-1.org with esmtps (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1YZiXc-000747-Ns; Sun, 22 Mar 2015 16:15:56 +0000 Original-Received: from localhost ([::1] helo=violet.siamics.net) by violet.siamics.net with esmtps (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1YZiXV-0005Ej-Gp; Sun, 22 Mar 2015 23:15:49 +0700 Mail-Followup-To: 20154@debbugs.gnu.org, Dmitry Gutov In-Reply-To: <550ED713.2010201@yandex.ru> (Dmitry Gutov's message of "Sun, 22 Mar 2015 16:52:03 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:100784 Archived-At: >>>>> Dmitry Gutov writes: > (defun json-encode-string-3 (string) > "Return a JSON representation of STRING." > (let ((l (length string)) > (start 0) > (res (list "\""))) > ;; Skip over ASCIIish printable characters. > (while (string-match "[\"\\/\b\f\n\r\t]\\|[^ -~]" string start) > (let* ((mb (match-beginning 0)) Why not =E2=80=98let=E2=80=99 mb above and use (while (setq mb (string-mat= ch =E2=80=A6)) =E2=80=A6) here (instead of going through match-beginning)? > (c (aref string mb)) > (special (rassoc c json-special-chars))) Is there a specific reason to prefer rassoc over rassq here? > (push (substring string start mb) res) > (push (if special > ;; Special JSON character (\n, \r, etc.). > (string ?\\ (car special)) > ;; Fallback: UCS code point in \uNNNN form. > (format "\\u%04x" c)) > res) > (setq start (1+ mb)))) > (push (substring string start l) res) > (push "\"" res) > (apply #'concat (nreverse res)))) I guess you can (apply #'concat "\"" (substring =E2=80=A6) (nreverse =E2= =80=A6)) just as well, instead of pushing to the list just before getting rid of it. [=E2=80=A6] > Please keep the discussion participants in Cc, even if you prefer not > to receive the copy email. Curiously, per my experience, the practice of Cc:-ing the subscribers tends to be frowned upon when it comes to the lists dedicated to free software. For the reasons I do not know or understand, Emacs lists are apparently an exception, though. I don=E2=80=99t seem to recall any issues with me trying to stick to the custom (of /not/ Cc:-ing) I=E2=80=99ve learned earlier; but if necessary, I surely can remember to Cc: those who so request. --=20 FSF associate member #7257 http://boycottsystemd.org/ =E2=80=A6 3013 B6A0= 230E 334A