emacs-devel
[Top][All Lists]
Advanced

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

Re: JSON/YAML/TOML/etc. parsing performance


From: Philipp Stephani
Subject: Re: JSON/YAML/TOML/etc. parsing performance
Date: Sun, 29 Oct 2017 20:48:02 +0000



Paul Eggert <address@hidden> schrieb am Mo., 9. Okt. 2017 um 07:54 Uhr:
Philipp Stephani wrote:
> I don't understand why minimizing the number of checks and assertions
> should be a worthwhile goal. At the very least, the assertions document the
> assumptions that we make about the values, and as such they are valuable
> even if they never trigger.

One can take the process too far. To take a deliberately extreme example,
'eassert (INT_MIN < 0)' would clutter the code unnecessarily, and would be
discarded by the compiler anyway. Although none of the assertions in question
were *that* obvious, some did have that flavor (and indeed, were optimized away
by GCC). The patch that I proposed eliminated those, while retaining the ones
that conveyed useful and nonobvious information. Admittedly some of the removals
were judgment calls; however, the point remains that easserts should not waste
the reader's time unnecessarily.

I agree, but I think anything that's not obvious deserves to be documented (preferably in the form of an assertion). Such documentation avoids the need to search for other places in the codebase and figuring out which invariants are guaranteed from the implementation. INT_MIN < 0 is already guaranteed by the C standard (although even that is somewhat subtle, given the possibility of different widths and representations of integers, padding bits, etc.),

reply via email to

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