From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#40693: 28.0.50; json-encode-alist changes alist Date: Wed, 29 Apr 2020 17:28:05 +0300 Message-ID: <349d9b1b-4659-907e-c6e1-30cdf052c87f@yandex.ru> References: <87a738jotd.fsf@tcd.ie> <87mu6utxd1.fsf@tcd.ie> <83r1w6ziql.fsf@gnu.org> <82572c3f-fb24-0b01-06ec-47067d9219ca@yandex.ru> <83blnazdly.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="6504"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 Cc: contovob@tcd.ie, darthandrus@gmail.com, 40693@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Apr 29 16:32:07 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jTnkt-0001WF-4x for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 29 Apr 2020 16:32:07 +0200 Original-Received: from localhost ([::1]:59746 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTnks-0002Fh-4Z for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 29 Apr 2020 10:32:06 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48240) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTniT-0008SS-Cu for bug-gnu-emacs@gnu.org; Wed, 29 Apr 2020 10:29:50 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTnhu-0008Id-Cj for bug-gnu-emacs@gnu.org; Wed, 29 Apr 2020 10:29:37 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60859) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jTnht-0008IE-W1 for bug-gnu-emacs@gnu.org; Wed, 29 Apr 2020 10:29:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jTnht-0007lg-TO for bug-gnu-emacs@gnu.org; Wed, 29 Apr 2020 10:29:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 29 Apr 2020 14:29:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 40693 X-GNU-PR-Package: emacs Original-Received: via spool by 40693-submit@debbugs.gnu.org id=B40693.158817050729789 (code B ref 40693); Wed, 29 Apr 2020 14:29:01 +0000 Original-Received: (at 40693) by debbugs.gnu.org; 29 Apr 2020 14:28:27 +0000 Original-Received: from localhost ([127.0.0.1]:44172 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jTnhK-0007kP-Nl for submit@debbugs.gnu.org; Wed, 29 Apr 2020 10:28:27 -0400 Original-Received: from mail-wm1-f51.google.com ([209.85.128.51]:33967) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jTnh7-0007jy-Gd for 40693@debbugs.gnu.org; Wed, 29 Apr 2020 10:28:25 -0400 Original-Received: by mail-wm1-f51.google.com with SMTP id v4so5071435wme.1 for <40693@debbugs.gnu.org>; Wed, 29 Apr 2020 07:28:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=aY45RHq+YqhW/30iSpWl9hlpAvW9uCFGhOIUbAuXTU4=; b=KkXNR75IRySXIhXuzZDaBEQR75bWEGZj7RfhfVJzdCOiVHjMuYkvQI/kLmA9tOY+b8 WkZS0D9r/ikmgnqo6WuxHI0Wevjy+YE1THpC6FbtYf+VFUaL1Iail+pEgv+VyM5il34j o7knOhj3rcLV3zNz5IGF9oR8cGZgrVEbIE7iFlfQb0oFjHRi1IaG5Ylq7IgGQiF87nOX vckUTIyyXF1WzE0gDxJdQm0BLPdgCRlQ1gIP3fkx6rP9gGDEH9zDEOXzKCRXRWQW8pKq ZWCJA7Qi+6mcK89iFpT4z1H0puW/kZFWjr/QJ4d5/NuUmgDn1IBbkwJ/jUEa4a4XeTJn TwTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=aY45RHq+YqhW/30iSpWl9hlpAvW9uCFGhOIUbAuXTU4=; b=s11Cn2iK1F85SPylM3U7YuhiKZyj3woAVLB0dm5b63wAE/B0cZsjCBFvezwFE6S2nf WD9KeBNGdbVW/ahHdoxdw2g7tClbY636YiLy55T8hUsVhGhZ2vg7w+UmKp65CZNjQfED C8GEx8CuNYkOwQm5STenmNfA3Wrx6ZLUs1uZHz3uVYFZbI1Zp3jxFmlLgmrVwwnzlkb3 1HFnXpLJfZ6Ph9DRzzU20687yFNuQCH0YXZxvV9gGqCwUcrU3191OpkPbhukcS9jmX6J 7E1Uxw3Ppe7dQYTzYc2pZV2TJtkQUTjnKuyOF4QItDyx2K6LlWZXCwy6WRueJypeDV9Q vLvg== X-Gm-Message-State: AGi0PuaUm5SKB8RrgktckM7Ww+tm7LLlWJ6K0IhwKbMerXoTEHHPx0DT FaMnPZlMkCPmEpM7ehQb3mV03e/jf1M= X-Google-Smtp-Source: APiQypJsbOblikEY2kHSY2dLWlxVpJ3sEyZhGBvNQCz9hBrwcL/GKyl12Pa9svTX5wDkijGZ5JtUZg== X-Received: by 2002:a1c:2d14:: with SMTP id t20mr3731571wmt.28.1588170487361; Wed, 29 Apr 2020 07:28:07 -0700 (PDT) Original-Received: from [192.168.0.2] ([66.205.73.129]) by smtp.googlemail.com with ESMTPSA id m14sm30192439wrs.76.2020.04.29.07.28.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Apr 2020 07:28:06 -0700 (PDT) In-Reply-To: <83blnazdly.fsf@gnu.org> Content-Language: en-US X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Received-From: 209.51.188.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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:179310 Archived-At: On 29.04.2020 15:21, Eli Zaretskii wrote: >> Cc: darthandrus@gmail.com, 40693@debbugs.gnu.org >> From: Dmitry Gutov >> Date: Wed, 29 Apr 2020 15:08:57 +0300 >> >>> No one tried to come up with arguments why this has to be in emacs-27. >> >> Let me try: >> >> It fixes a bug, one which could be annoying to investigate, the fix is >> small and localized to the case when json-encoding-object-sort-predicate >> is non-nil (so pretty safe). > > It also makes the function slower. Which may be an important issue > for JSON processing. Callers that don't care about the original list > will be "punished" regardless. It's a somewhat fair point (copy-sequence is much faster than sort, usually, but if we include GC time, it can be significant). The way json-encoding-object-sort-predicate is implemented, though, it's not very performance-oriented. Applications like lsp-mode aren't going to use this variable, so they shouldn't be hit (and it isn't supported in native JSON either). On that subject, users really shouldn't set it either. Rather, any user-facing feature that outputs JSON, when this behavior could be desirable, should have its own tweaking knob. > How about adding an optional argument instead, by default off, to > request this behavior? then callers who care about the original alist > could request a non-destructive operation, and others won't suffer any > slowdown. The current behavior is unsafe, that's the problem. Also, json-encode-alist is called in a recursive fashion, so it'd have to be a global variable instead.