This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: kawa-java string compatibility proposal


On Thursday 03 March 2005 21:39, Per Bothner wrote:
> Jim White wrote:
>  >and <mutable-string> be j.l.StringBuffer?
> 
> In that case might as well make it char[] - though that doesn't
> implement CharSequence.

StringBuffer is significantly faster than char[] in many cases.
Converting a char[] instance to a String via new String(char[]) always
involves copying.

Converting a StringBuffer to String via StringBuffer#toString()
involves no copying, provided the StringBuffer instance is never
mutated after you call toString() on it.  This is because StringBuffer
and String are usually optimized to share the same underlying
character array via the copy-on-write arrangement.  If there is no
"write", then there is no "copy".


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