News for hackers. Stuff that matters.
Re:Parsing can become accidentally quadratic because of sscanf by birktj on Monday March 01, 2021 @01:16PM (#26305981)
As is the case in this article it often happens that having the length of a string is required for certain operations, which leads to a lot of calls to strlen. This doesn't really seem like such a big problem to begin with as one assumes that the operations that require the length also have linear complexity. However it turns out (like in the article) that this is not always the case which leads to unexpected quadratic algorithms. The pointer + length representation is only 7 bytes longer on modern architectures and does not have this problem and has a few other advantages like being able to create substrings without allocating new memory.
Re:Parsing can become accidentally quadratic because of sscanf by wnoise on Monday March 01, 2021 @02:01PM (#26306681)
In fact, having the length of the string was not required. Certain ways of implementing scanf() required getting the length of the string, or otherwise scanning the whole thing.

But saner ways did not.