Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!nuzba.szn.dk!pnx.dk!fu-berlin.de!uni-berlin.de!news.dfncis.de!not-for-mail From: =?ISO-8859-1?Q?Sven_K=F6hler?= Newsgroups: comp.lang.java.programmer Subject: Re: simple StringBuilder proposal Date: Wed, 27 Feb 2013 03:47:24 +0100 Lines: 46 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: news.dfncis.de jTfnObgN6jZ8T+CUonlx1wSTFcq1BVcnKLWgyTKpR8XHcxT/QXrWyAy4l+ Cancel-Lock: sha1:cwhv9RC6Q3wPbiE5ONk4TO8vJ1w= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130223 Thunderbird/17.0.3 In-Reply-To: Xref: csiph.com comp.lang.java.programmer:22562 Hi, Am 26.02.2013 12:53, schrieb Roedy Green: > With FastCat, I can write: > > sb.append( " ":", cseCode, "\">\n" ); So I googled and found a FastCat class that has append(String ...) and append(Object ...) methods. And just by coincidence, you're a co-author of that class. So basically, whatever arguments you pass, they are first wrapped in an array, and then passed to the append method. To make things worse, if you'd pass a mix of char, int, double, etc. - some of these things would first be wrapped in Char, Integer, Double, etc. - and then the toString() method is called. > It is just shorthand for > > sb.append( " sb.append(cseAccount); > sb.append(":"); > sb.append(cseCode); > sb.append( "\">\n" ); No it is not. > I propose StringBuilder learn the same trick. So, are you aware of the performance hit? Are you trying to say, that you prefer convenience over performance here? And if you don't care about performance in this particular case, why don't you use the + operator for Strings which is pretty convenient? Or why don't you exploit the fact that append() returns the StringBuilder instance? I'm not sure, what to make of your posting. Are you just trying to promote the FastCat class? Would you happen to have a benchmark, where you append lots of integers to a FastCat and a StringBuilder? I would love to see what happens if you use the append(Object...) method for that. Regards, Sven