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: Mattias EngdegÄrd <mattias.engdegard <at> gmail.com>
To: 79192 <at> debbugs.gnu.org
Subject: bug#79192: json parsing error position reform
Date: Thu, 7 Aug 2025 17:19:48 +0200
[Message part 1 (text/plain, inline)]
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.

There's a patch. Surprisingly, it speeds up the parsing part by more than 10 % which is definitely worthwhile.

[jsonspeed.diff (application/octet-stream, attachment)]

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.