Does using strlen
actually count the number of bytes in the string by iterating through the string, or does it simple return the value of an already calculated length of the string from an index?
The reason for my question is because I have a choice to store pre-calculated values of very long strings for a speed-sensitive script, or I could just use the strlen
function and save myself coding time.
But I would actually like to know how strlen
works as I tend to rely on it a lot, and perhaps this is not a good idea?
UPDATE
See my benchmark below.