bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#40693: 28.0.50; json-encode-alist changes alist


From: Dmitry Gutov
Subject: bug#40693: 28.0.50; json-encode-alist changes alist
Date: Wed, 29 Apr 2020 17:28:05 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0

On 29.04.2020 15:21, Eli Zaretskii wrote:
Cc: darthandrus@gmail.com, 40693@debbugs.gnu.org
From: Dmitry Gutov <dgutov@yandex.ru>
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.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]