Return-Path: Delivered-To: apmail-ant-dev-archive@www.apache.org Received: (qmail 96338 invoked from network); 20 Apr 2006 04:01:10 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 20 Apr 2006 04:01:10 -0000 Received: (qmail 79973 invoked by uid 500); 20 Apr 2006 04:01:09 -0000 Delivered-To: apmail-ant-dev-archive@ant.apache.org Received: (qmail 79917 invoked by uid 500); 20 Apr 2006 04:01:08 -0000 Mailing-List: contact dev-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list dev@ant.apache.org Received: (qmail 79906 invoked by uid 99); 20 Apr 2006 04:01:08 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Apr 2006 21:01:08 -0700 X-ASF-Spam-Status: No, hits=1.4 required=10.0 tests=DNS_FROM_RFC_ABUSE,DNS_FROM_RFC_WHOIS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [68.142.200.155] (HELO web30902.mail.mud.yahoo.com) (68.142.200.155) by apache.org (qpsmtpd/0.29) with SMTP; Wed, 19 Apr 2006 21:01:07 -0700 Received: (qmail 95704 invoked by uid 60001); 20 Apr 2006 04:00:46 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=0v/DwKB+/iVMVAnwGZTAOaAZy33uuJ4mvGN97VrkCrkTEn8Fg5A0vsuZakyaVQqxCPoQnQjpIfuO78K8pr9qdMBdkzgW+jMgX/IW2hmVY4RUPpb0Ly/xxzeHlOSop+9jsSYnm6QndK70dYiuz8PMM3ebkYLsQnEMPVn1xke0RSw= ; Message-ID: <20060420040046.95702.qmail@web30902.mail.mud.yahoo.com> Received: from [172.136.230.102] by web30902.mail.mud.yahoo.com via HTTP; Wed, 19 Apr 2006 21:00:46 PDT Date: Wed, 19 Apr 2006 21:00:46 -0700 (PDT) From: Matt Benson Subject: Re: AW: Adding a methof to StringUtils To: Ant Developers List In-Reply-To: <4446EC20.5020405@it.fts-vn.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N --- Kev Jackson wrote: > Dominique Devienne wrote: > > >>The point about building the strings when they > aren't used (because > >>logging verbosity is set too low) still stands > though - this is less > >>than efficient > >> > >> > > > >The point, which Matt already raised, is that you > can't know the level > >at which the logger and the listeners are set. > There is nothing ATM in > >the Ant codebase to tip off the project as to the > min log level of all > >logger+listener to implement your optimization. > This could be can be > >added though, and would be useful IMHO, but that's > a separate thread. > > > > > > > I know, that was why I didn't want to wrap the log > code in if(verbosity > >= Project.MSG_INFO) conditionals - it's sort of a > catch-22 situation, > you don't want to log the message (or even bother > building it) if it > won't be used, but that can't be determined, so you > must build the > message just in case - I agree a mechanism for you > to retrieve the > minimum logging level of the entire project would be > useful in this > situation > > >The StringBuffer optimization is well known. I've > either read about it > >in Effective Java or the "K&R" of Java, > The.Java.Prog.Lang. > > > > > I think it was in Effective Java, but as Alexey > showed previously, > Java1.4+ actually perform this operation for you, > letting you be as lazy > as you like with String concatenation (now that's > progress!). I have to > stop beating up the junior devs here whenever I see > sqlString = "Select > " + field + " from " + table + " where " + field + " > = value"; as we are > on 1.4 internally so it doesn't degrade performance > anymore. Still I'd > prefer to be able to do something like "yada yada > ${var1} yada yada > ${var2}" like the property expansion that is already > in Ant - I > personally think it's much cleaner than "yada yada " > + var1 + "yada > yada" + var2., even the Java5 printf isn't as nice > as it could be for > constructing messages (although it's a long way > forward). > > >I think what you propose to do would clutter the > code, and make it > >ugly frankly ;-) I'd probably -1 it unless you can > show hard evidence > >of it's usefulness. > > > > > If it came to it I'd -1 it too! I don't like any of > the solutions I > could come up with yesterday, the one I showed was > the 'least worst' > that I could think of, with a semi-upgrade path to > Java5 style varargs > (use an object array). I was mainly throwing the > idea out to see what > peoples reactions were - overall I don't think it's > the right way to > solve the problem - the real problem is that the > level of logging cannot > currently be determined and so any optimization (for > memory or > performance) is actually changing the behaviour of > the code - which it > shouldn't do. > > The delete task was just an example - I was looking > at it to fix 'delete > task won't be quiet' bug in bugzilla, and I was also > thinking about the > problem with AppFuse, (which does use Delete a > little, but not as much > as Copy and other tasks), so it seemed like a handy > guinea pig as I had > the code open at the time. > > I was also looking at Copy and saw that > ResourceUtils.copyResource is a > static method, but FileUtils.copyFile is not even > though it delegates to > copyResource, this means that in Copy there must be > an instantiated > fileUtils object, just to perform the copy, > unfortunately the FileUtils > interface/API is public so changing it would break > bwc, but I'd like to > add a static method for copyFile so that Copy wont > need to instantiate > FileUtils. Kev: I've asked some stuff about FileUtils before... historically it was thought it might be pluggable, hence all the instance methods. But that never happened so the static methods crept in. I think it was Martijn who really pushed in the FileUtils singleton. Most places in Ant's code don't instantiate their own FileUtils anymore, and if they do they shouldn't; they should use the singleton. -Matt > > Thanks everyone for feedback > Kev > > --------------------------------------------------------------------- > To unsubscribe, e-mail: > dev-unsubscribe@ant.apache.org > For additional commands, e-mail: > dev-help@ant.apache.org > > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For additional commands, e-mail: dev-help@ant.apache.org