Thu May 17 12:01:00 GMT 2001
On 17 May 2001, Tom Tromey wrote:
> This isn't really what I was getting at though. If we are making a
> substring of a String which is already small, then copying it seems
> less efficient than referring to it.
I have a hunch that if a string is small enough to fit entirely in one
cache line (typically 32 or 64 bytes) then the cost of copying is
negligible compared to the potential avoidance of a cache or TLB miss.
Most strings with length <= 8 would fit that category.
But that's just a guess. Supporting data sure would be nice. I wonder if
any of the free XML parsers would exercise substring() suitably?
It may well turn out that the answer is machine-dependent too.
Optimizations that are good for my Alpha sometimes do the reverse on x86,
More information about the Java