I have read that use of strlen is more expensive than such testing like this:
strlen
We have a string x 100 characters long.
x
I think that<
If no there's no compilation optimization. Yes because strlen will iterate on every byte of the string every time and the second implementation will do it only once.