3 ms·
> It says at worst later, talking about if there is no match. The article says “len*2 at worst”. There is no intervening text, that’s a direct quote. > It hea
by klodolph 6y ago
> It says at worst later, talking about if there is no match.
The article says “len*2 at worst”. There is no intervening text, that’s a direct quote.
> It heavily implies that there's 2 accesses per byte always.
This interpretation is incorrect. The article does not imply this.
- mlyle 6y ago"You see, there are two memory accesses per one character of the input string." It says this, DIRECTLY, not qualifying it as "up to" or "worst case". The next sentence says it can be 2*len, e.g. if you scan the entire length. Those two sentences feel like something that someone would write if they didn't understand short circuit evaluation. You read it differently, but your opinion of how it is intended isn't sufficient to refute my interpretation of the text.
- klodolph 6y agoIt seems much more plausible to me that the author does understand short-circuit evaluation, but did not feel like explaining it in such detail to satisfy the tedious pedantry of HN comments. My experience with writing answers Stack Overflow is that people in the comments will always figure out a way to interpret an answer as being incorrect, and latch onto it. There is a tradeoff between clarity and pedantry. You don’t want to simplify something too much where it is no longer insightful, and you don’t want to write something with irrelevant detail that obscures the point you are trying to make.
- mlyle 6y agoI really don't think the author is fluent in C. They consistently put semicolons after brackets, and they have off-by-1 errors in array indexing, etc (the first search_ok looks past the end of string; the second search_ok won't see ok in the string "ok"). That's part of why I read it that way. I understand the concern over excessive pedantry.
- klodolph 6y agoMy experience is that C programmers with many years of experience will still make off-by-one errors. Most of the examples have the correct bounds. The semicolons don’t belong but… so what? If you wish to report errors to the author, there is an email address at the bottom: > Please drop me email about bug(s) and/or suggestion(s):