Would it be an idea to add a CONTAINS_ZERO flag to the new string flag field, so we can rid the code of all O(n) if(strlen(s->str)!=s->len)?
Probably not; keeping the flag valid would probably have quite some overhead. Note also that most of the places that have that sort of code handles short strings (eg filenames), where the cost for doing strlen() is small.
I guess my thought was that in many places we know that the string we create contains no NULL (make_shared_string/make_shared_binary_string). And when we do check for NULL we might as well save that result. So unless it is easy to add a check during the hashing we could use two bits to save the result of a NULL check, which nicely enough will be shared as strings are shared. But perhaps someone can come up with a better use for these two bits...
pike-devel@lists.lysator.liu.se