This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
RE: String.substring() question
- To: "'tromey at redhat dot com'" <tromey at redhat dot com>, Java Discuss List <java at gcc dot gnu dot org>
- Subject: RE: String.substring() question
- From: "Boehm, Hans" <hans_boehm at hp dot com>
- Date: Wed, 16 May 2001 17:28:05 -0700
> From: Tom Tromey [mailto:tromey@redhat.com]
>
> Right now String.substring() always creates a reference to the old
> string's data. I wonder if that is always what we want. I think
> perhaps if the old String is very large and the new substring is very
> small, then we might consider making a copy.
That will have the added advantage that the collector won't have to ever
look at the new string. That matters if it's very long-lived. I have no
idea how often that happens in practice.
> Or maybe for very large
> Strings we could consider playing some game involving weak references?
I suspect that it's almost always cheaper to copy a short string then to
generate a weak reference.
> Or maybe this is a nonissue -- maybe people don't make huge Strings
> often enough for it to be worthwhile.
>
> I'm not aware of any data that would help us make these sorts of
> decisions. Bummer.
Neither am I.
Hans