GNU bug report logs - #79192
json parsing error position reform

Previous Next

Package: emacs;

Reported by: Mattias Engdegård <mattias.engdegard <at> gmail.com>

Date: Thu, 7 Aug 2025 15:21:01 UTC

Severity: normal

Full log


View this message in rfc822 format

From: Eli Zaretskii <eliz <at> gnu.org>
To: Mattias Engdegård <mattias.engdegard <at> gmail.com>
Cc: 79192 <at> debbugs.gnu.org
Subject: bug#79192: json parsing error position reform
Date: Thu, 07 Aug 2025 18:36:16 +0300
> From: Mattias Engdegård <mattias.engdegard <at> gmail.com>
> Date: Thu, 7 Aug 2025 17:19:48 +0200
> 
> The json parser (src/json.c) spends a surprising amount of time keeping track of the current line and column, on the off chance that an error occurs in which case that information would helpfully be included. This is a bad design in a variety of ways:
> 
> (1) It goes against all performance engineering to spend resources on maintaining information that is unlikely to be used.
> (2) JSON parse errors aren't expected to occur during normal operation.
> (3) From what I can tell, nobody uses the position information of the json-error signal at all.
> (4) One reason for (3) is that it isn't documented anywhere.
> (5) Even if someone would find the position useful, there is no evidence that they would need the line and column (which could easily be derived from the position).
> 
> So let's remove at least the line and column of the error position. We can still supply the position from the start of the parse because we have the information anyway.

If we have the position, can we have the cake and eat it, too?  Would
it be possible to call some function in the case of an error that
would calculate the line and column from the position, and include
that in the error data?  That way, the performance will suffer only
when there is an error to report.

Another idea is to disable this conditionally, so that if someone
really needs this, they could have it for the price of somewhat slower
parsing.




This bug report was last modified 7 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.