Alejandro Colomar wrote:
> This finds the first non-'/'.  Since the first character is a '/' (we
> have set that a few lines above in `*slash = '/';`), we were manually
> skipping it.

That's the perfect way to write such a thing.

> However, that's unnecessary, since the function will
> similarly skip it.
> 
> It seems a benign off-by-one mental bug, which didn't result in any
> actual bug, but still worth "fixing", or rather, simplifying.

No, that's not a simplification, but adding a computation that we already
know is unnecessary (and that the compiler typically will not optimize away).

De-optimization is OK when it improves maintainability. But here, it doesn't
do so. As a programmer, one only needs to look 3 lines above to see why the
code is correct.

Bruno




Reply via email to