 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Roedy Green Guest
|
Posted: Sun Nov 27, 2011 8:30 am Post subject: smarter char[] and byte[] |
|
|
I was disturbed to find out how much time Java spends copying char[]
and byte[]. Most of the time it has composed something and copies it
into a smaller array for future use.
I suggest we invent something that is a cross between a char[] /
byte[] and an ArrayList that would more efficient than either.
For example, let say you have some code that builds a String. It
composes char is a char[], but not quite fill it up. So it copies it
to a char[] just the right size, and puts a reference to it inside the
String.
What I suggest should happen instead is the oversized char[] should be
linked into the String, without copying. Usually the object will die
before the next GC. We have used even less RAM than had we copied.
Let's say this object survives to GC. AT THAT TIME the char array is
shrunk to fit. So you only bother with the copy when it pays off.
--
Roedy Green Canadian Mind Products
http://mindprod.com
How long till someone puts out a car navigator with the realistic
side comments of a real back seat driver. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|