If I'm not mistaken, the statement
if (pc >= end) return false;
is logically equivalent to the next statement
if (end - pc < 1) return false;
If that's the case, the PR removes the former for better efficiency and code readability.
If I'm not mistaken, the statement
if (pc >= end) return false;
is logically equivalent to the next statement
if (end - pc < 1) return false;
If that's the case, the PR removes the former for better efficiency and code readability.
For readability I guess removing the latter and keeping the former would be more clear. Also it's less instructions actually (single comparison vs subtraction (a pointer diff!) and a comparison).
The former also returns false if pc and end are equal, while the latter does not.
Thank you @scravy for your comment, that's good points. I chose to keep the pattern of the latter as it is used repeatedly in the rest of the function whereas the former is not. I will modify the PR to keep the former instead if that the preference of the majority.
@andrewtoth the latter also returns false as 0 < 1 is true, which then returns false.
Oops right.
It's a great find, but ultimately removing such a check is not worth it given the sensitivity of this code, especially if it makes the code less readable. The optimizer should optimize this in any case.
Nack
Agree with @JeremyRand.
@r8921039: if you're looking for places to contribute, look at the contributor guidelines and good first issue list.
Totally understandable, thanks you all for the reviews and comments.
If you are looking for small things to help out with, you can