No subject
Sat Nov 12 19:29:10 PST 2005
-- snip --
public String (StringBuffer buffer) {
synchronized(buffer) {
buffer.setShared();
this.value = buffer.getValue();
this.offset = 0;
this.count = buffer.length();
}
}
-- snip --
Knowing the basic semantics of StringBuffer expansion ... this code appears
to me to allow the immutable String object to wrap a char[] that may be
larger than the string itself. And in fact ... I would bet that in the
average case where StringBuffers are being used ... the programmer is
relying on the basic semantics provided by StringBuffer for expansion ...
which I would bet means that the char[] is quite often larger than the
string itself.
Further, I wonder what happens when you then intern() a String whose char[]
is "oversized".
I *think* I understand the intent ... but I suspect that in practice ...
this turns out to be optimal less often than when it isn't ...
thoughts ?
Tony
---
To unsubscribe, mail advanced-java-unsubscribe at xcf.berkeley.edu
To get help, mail advanced-java-help at xcf.berkeley.edu
More information about the Advanced-java
mailing list