Subject: Re: bug#79192: json parsing error position reform

From: Eli Zaretskii <[email-masked]>
Date: Thu, 07 Aug 2025 18:36:16 +0300

> From: Mattias Engdegård <[email-masked]>
> 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.