From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?UTF-8?Q?Cl=c3=a9ment_Pit-Claudel?= Newsgroups: gmane.emacs.devel Subject: Re: JSON->lisp Mapping: Hash vs AList Date: Mon, 18 Dec 2017 11:15:14 -0500 Message-ID: <49ce1429-228e-a92a-839f-312d6171e896@gmail.com> References: <838te5uvee.fsf@gnu.org> <838te1qrkq.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1513613611 23853 195.159.176.226 (18 Dec 2017 16:13:31 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 18 Dec 2017 16:13:31 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Dec 18 17:13:27 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eQy2g-0005mF-OW for ged-emacs-devel@m.gmane.org; Mon, 18 Dec 2017 17:13:26 +0100 Original-Received: from localhost ([::1]:52566 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQy4d-0006i1-HF for ged-emacs-devel@m.gmane.org; Mon, 18 Dec 2017 11:15:27 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36630) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQy4U-0006ek-If for emacs-devel@gnu.org; Mon, 18 Dec 2017 11:15:19 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eQy4T-0004Ds-02 for emacs-devel@gnu.org; Mon, 18 Dec 2017 11:15:18 -0500 Original-Received: from mail-qk0-x22e.google.com ([2607:f8b0:400d:c09::22e]:36162) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eQy4S-0004CX-NC for emacs-devel@gnu.org; Mon, 18 Dec 2017 11:15:16 -0500 Original-Received: by mail-qk0-x22e.google.com with SMTP id 8so18944160qkj.3 for ; Mon, 18 Dec 2017 08:15:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=VckMGooWCqbAZEgYpteQIQ1yQF9cdLFrv1QIukEiUeE=; b=UMfjdW5qyBgrQNo4y6fXM8HKtfiZX8lntVD/HhAof6m2Hxq1fMcC4tledPC2RWJBKw qTKbW8ZoXu5Q4gIOgYd3+19iW/mjMqpkm0SYSGfzbIpA3vJ2c1NQVFPKwEWJr41tTZjk hudXTlv8Qu0LEiPu9TpppjLKeIaW17rV6Q/agsE0YN47B/DKn/mubk5SDMnqC0t872xf dfxnppMr1bwC+3H4SfGOCT0nkYxAZf2FDcRlI+mgfgD173gN+RcfxtcfDuhHy/rB+Qh9 wd5uiYdewasGL3F5rZImMV+m78CtKJvHqXky2jtO561UvbmOzyJnr1scrNxhUA7mENlm zFCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=VckMGooWCqbAZEgYpteQIQ1yQF9cdLFrv1QIukEiUeE=; b=NXxUJjrsW4C86ZRxWgSCuM3CgLvY61pdqQ0XUKKxUyvQo/h2N2vnlDTeKJv/Vd5YCP vJT66viJCjcwa0W6dBIe0kS6GDNAxxf9+IQKGyurikNEY2W4eL2iB8JOXqDTzvK5gldY LhlHAXv+s6zHOuPwBjftRy/WCXvBhaITHq7yyY2c5RVollWaiw3MGguGzFrmaDtUXHz7 LTqrLBcg4jWg32y4qTQ+xwUKA6NUsU0h2RAO+l4KC7ilckaxXLO47cDDN6MgYWI1gFMr OuFKf+u3IshRBPfhNVUaNdKD9tJEz99AVE9CnIUtV/XLGcg9HJP1GWp/erRixKs0G+sb 0ZpA== X-Gm-Message-State: AKGB3mJq092aRBqvQ3+ujOsfu7RUPc1oVxybrSrVFwgVyAqvix82SykE TdKP0lHDcW6StR03Gn7c1MgFaRtJ X-Google-Smtp-Source: ACJfBotxBjydzMcrjGzFzZd0+8kHU+RVJbRJ749QFHp9awpU1HLASD25PsaDIRjN0suboDsy1ezx7A== X-Received: by 10.55.143.193 with SMTP id r184mr127711qkd.169.1513613715795; Mon, 18 Dec 2017 08:15:15 -0800 (PST) Original-Received: from ?IPv6:2601:184:4180:66e7:c554:339d:76d1:d529? ([2601:184:4180:66e7:c554:339d:76d1:d529]) by smtp.gmail.com with ESMTPSA id k34sm8350669qtk.5.2017.12.18.08.15.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Dec 2017 08:15:15 -0800 (PST) In-Reply-To: Content-Language: en-GB X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::22e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:221219 Archived-At: On 2017-12-17 12:44, Philipp Stephani wrote: > >  > +              result = Fnreverse (result); > > > >  Is there a reason for calling nreverse here? > > > > It puts the elements in the same order as the original JSON. (The Jansson parser also retains the original > > order.) > > This isn't very important, just a bit nicer and less surprising. > > It's a potential performance hit, but if you think it's worthwhile, > it's fine with me. > > I don't care much. For now I'd leave it in, we can take it out later if it hurts performance too much. (Though people that care about performance should probably use hashtables anyway.) Would it make it faster to construct the list in order, instead of constructing it in reverse and then reversing it? Something like the following, but in C: ;; the direct version (defun map-fn-over-list (fn list) (when list (let* ((out (cons (funcall fn (pop list)) nil)) (lastcdr out)) (while list (setcdr lastcdr (cons (funcall fn (pop list)) nil)) (setq lastcdr (cdr lastcdr))) out))) Clément.