Open JeffBezanson opened 4 years ago
Would it make sense to add this to all large immutable objects?
Other objects are less likely to be used as a hash and/or large.
I guess this brings up the question too of whether we should cache length
and isascii
and isvalid
and other common queries with O(1)
storage for these larger strings too.
Yep, see #33712.
For strings over a certain size threshold, it seems like it would be an easy win to allocate an extra word at the end of the string data to cache its hash value. For example, this could dramatically speed up de-duplication in the serializer when there are many references to the same large string object.