Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!nuzba.szn.dk!pnx.dk!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Robert Klemme Newsgroups: comp.lang.java.programmer Subject: Re: simple StringBuilder proposal Date: Tue, 26 Feb 2013 22:53:45 +0100 Lines: 35 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net xUdLurdWOet1LR9GGkiWNgOFeCoOrzMczXdMuMUhHkOK4+K3A= Cancel-Lock: sha1:3bUuQ5s5dgdbIRIJ3LJsUHgciiw= User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64; rv:17.0) Gecko/20130215 Thunderbird/17.0.3 In-Reply-To: Xref: csiph.com comp.lang.java.programmer:22555 On 26.02.2013 19:47, markspace wrote: > This is a point. I think that the varagrs method might be notably > inefficient in many cases, as primitives would be autoboxed. However, > it would not hurt to actually investigate this and determine how much > and how often the autoboxing becomes an issue. That investigation I'll > leave to the concerned parties, however. Please don't forget the Object[] creation which is imposed for every such call. I cannot really recall what class it was but there is a class which has an overloaded method with single arguments for the case 1 to 3 and then has a catch all with vararg. Like this void f() void f(Object arg) void f(Object arg1, Object arg2) void f(Object arg1, Object arg2, Object arg3) void f(Object arg1, Object arg2, Object arg3, Object... remainder) Effective Java seems to have this pattern on page ~200 also. So someone clearly must have assumed that this can be significant. I'd say the effect is worst for short argument lists, i.e, if you have only the vararg method and pass just one argument then the overhead per instance is highest. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/