You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by COFFMAN Steven <SC...@CBSINC.com> on 2000/02/17 16:15:09 UTC

PDFStream

Hi,
	I might be quibbling over details, but how come PDFStream's data
object is a StringBuffer and not a String? Just for the append() method?
Isn't it StringBuffer slower and more overhead for no real gain? Wouldn't it
be better to avoid using StringBuffer.append(s) and instead use
PDFStream.add(s)?
Rewrite:
Original:
    public void add(String s) { //data is a StringBuffer
	this.data = this.data.append(s);
    }
New:
    public void add(String s) {//data is a String
         this.data=new String(this.data+s)
    }

Anyway, I've been messing around with using the PDF* classes of FOP to
produce Vector graphics in my PDFs, and I wondered if there was a reason.

Re: PDFStream

Posted by Fotis Jannidis <Fo...@lrz.uni-muenchen.de>.
> 	I might be quibbling over details, but how come PDFStream's data
> object is a StringBuffer and not a String? Just for the append() method?
> Isn't it StringBuffer slower and more overhead for no real gain? 

AFAIK StringBuffer is more efficient compared to Strings. Class String is immutable, so 
if you change a string in a String class what happens is that under the hood the whole 
thing is converted to StringBuffer, changed there and then converted back. Actually the 
inefficiency of the String class seems to be one of the weaker points of java. See p.e. 
the IBM article Pankaj Narula pointed to.

Fotis