This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: String.substring() question




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,
I find.

Jeff



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]