From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#21798: 25.0.50; [PATCH] Add support for retrieving paths to JSON elements Date: Tue, 3 Nov 2015 04:00:56 +0200 Message-ID: <56381558.7050607@yandex.ru> References: <1446281162.2607.0@smtp.gmail.com> <5634CEE7.3070200@yandex.ru> <1446407553.4906.0@smtp.gmail.com> <1446420466.13180.0@smtp.gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1446516142 19562 80.91.229.3 (3 Nov 2015 02:02:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 3 Nov 2015 02:02:22 +0000 (UTC) Cc: 21798@debbugs.gnu.org To: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Nov 03 03:02:09 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 1ZtQvI-0007Z4-TK for geb-bug-gnu-emacs@m.gmane.org; Tue, 03 Nov 2015 03:02:09 +0100 Original-Received: from localhost ([::1]:45169 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZtQvI-0000dA-97 for geb-bug-gnu-emacs@m.gmane.org; Mon, 02 Nov 2015 21:02:08 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46000) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZtQvF-0000cc-Ah for bug-gnu-emacs@gnu.org; Mon, 02 Nov 2015 21:02:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZtQvC-0006ms-2l for bug-gnu-emacs@gnu.org; Mon, 02 Nov 2015 21:02:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:59500) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZtQvB-0006mo-Vh for bug-gnu-emacs@gnu.org; Mon, 02 Nov 2015 21:02:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1ZtQvB-0003Sp-LS for bug-gnu-emacs@gnu.org; Mon, 02 Nov 2015 21:02:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 03 Nov 2015 02:02:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21798 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 21798-submit@debbugs.gnu.org id=B21798.144651606313248 (code B ref 21798); Tue, 03 Nov 2015 02:02:01 +0000 Original-Received: (at 21798) by debbugs.gnu.org; 3 Nov 2015 02:01:03 +0000 Original-Received: from localhost ([127.0.0.1]:50208 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZtQuE-0003Rb-QS for submit@debbugs.gnu.org; Mon, 02 Nov 2015 21:01:03 -0500 Original-Received: from mail-wm0-f43.google.com ([74.125.82.43]:33960) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZtQuB-0003R3-Tu for 21798@debbugs.gnu.org; Mon, 02 Nov 2015 21:01:00 -0500 Original-Received: by wmff134 with SMTP id f134so73218754wmf.1 for <21798@debbugs.gnu.org>; Mon, 02 Nov 2015 18:00:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-type:content-transfer-encoding; bh=qsHQ5O/4z5czDL2Ca7VSc4TQuVoLxWpvIGt/hWNPqgk=; b=U2CICnoX7352FzxrTBiw9vUnDE1Ic+RPqFPGW2pAB3xd+QyYuS0dBM7gQ7/TCGkTYq eoSkKD2gJ5eBLaU1u8lPw3vHvB6eh5lSuQ7rnm6P+UWoaCXvJz6q7KU/AM0sV6p1yD5i SCSM/DFDTf/Rw+Tw/wold9gWpv+BMH5O7yY97GY51EKRN4h2cjGgy4aH1TK2qzNgAVkF as/PJUz9olQ4KwJzu3s6J/qeMiQuiTrAZUGf5o2AUGFBDtrjTYs7jXJZpw3Y2xGK4GpM ZSlKF9lqB/XNFUzRToquNCbPokVamFMEoasg+EMqtiJTf/eTblwWPoe0yDom1mK18SJA vYmw== X-Received: by 10.28.215.205 with SMTP id o196mr17399795wmg.95.1446516058937; Mon, 02 Nov 2015 18:00:58 -0800 (PST) Original-Received: from [192.168.1.2] ([185.105.175.24]) by smtp.googlemail.com with ESMTPSA id j4sm21028275wmg.18.2015.11.02.18.00.57 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Nov 2015 18:00:57 -0800 (PST) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:42.0) Gecko/20100101 Thunderbird/42.0 In-Reply-To: <1446420466.13180.0@smtp.gmail.com> 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: 208.118.235.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:108334 Archived-At: Hello Simen, On 11/02/2015 01:27 AM, Simen Heggestøyl wrote: > I managed to produce a benchmark with the following JSON file (560K, > ~10,000 lines): http://folk.uio.no/simenheg/huge.json. > > I read it into `huge-json', and ran the following before the patch: ... Thanks. In my testing, too, the difference seems to be statistically insignificant. That's good. I have to say, I'm still not very comfortable with mixing it sort of alien logic inside json-read-object and json-read-array (would anyone else like to chime in with their opinion?). I do believe we want this functionality, though. One option to tighten the implementation is to extract common pieces from json-read-object and json-read-array, and implement two new functions using them, but the while-loops used there will make avoiding just copying code somewhat difficult. Here's an idea: both json-read-object-1 and json-read-array-2 will advise json-read to add the new logic around calls to it (there will have to be some guard in the advice, so that recursive calls are run unmodified). And json-path-to-position will locally modify json-readtable to use json-read-object-1 and json-read-array-2. That's just a suggestion, though.