This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: String.substring() question
- To: Tom Tromey <tromey at redhat dot com>
- Subject: Re: String.substring() question
- From: Jeff Sturm <jsturm at one-point dot com>
- Date: Thu, 17 May 2001 15:07:13 -0400 (EDT)
- cc: Per Bothner <per at bothner dot com>, Java Discuss List <java at gcc dot gnu dot org>
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