For Java 6 projects, I always use isEmpty(), unless the size needs to be cached for some reason.
Gary On Tue, Mar 4, 2014 at 10:10 AM, Simone Tripodi <[email protected]>wrote: > yeah that was my curiosity/question/concern: should both methods have 0 > impact on performances or not? > > I have no preferences as well, as Gary pointed on it reads better to me as > well but that's definitively not an issue :) > best, > -Simo > > http://people.apache.org/~simonetripodi/ > http://twitter.com/simonetripodi > > > On Mon, Mar 3, 2014 at 9:38 PM, Mark Thomas <[email protected]> wrote: > > > On 03/03/2014 16:31, Gary Gregory wrote: > > > It reads better to me. > > > > > > Gary > > > > > > -------- Original message -------- > > > From: Simone Tripodi <[email protected]> > > > Date:03/03/2014 10:40 (GMT-05:00) > > > To: Commons Developers List <[email protected]> > > > Subject: Re: svn commit: r1573561 - > > > /commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java > > > > > > Hi there, > > > just a matter of curiosity: would > > > > > > + if(traces != null && !traces.isEmpty() { > > > > > > be better or not compared to > > > > > > + if(traces != null && traces.size() > 0) { > > > > > > That should be the same, right? > > > > My only concern at this point is performance and that size() call is way > > below the noise level at this point. > > > > I have no objection if folks want to paint that bike shed a different > > colour as long as it has no measurable, negative impact on performance. > > > > Mark > > > > > > > TIA all the best > > > -Simo > > > > > > http://people.apache.org/~simonetripodi/ > > > http://twitter.com/simonetripodi > > > > > > > > > On Mon, Mar 3, 2014 at 2:43 PM, <[email protected]> wrote: > > > > > >> Author: markt > > >> Date: Mon Mar 3 13:43:28 2014 > > >> New Revision: 1573561 > > >> > > >> URL: http://svn.apache.org/r1573561 > > >> Log: > > >> Another small performance tweak. > > >> > > >> Modified: > > >> > > >> > > > commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java > > >> > > >> Modified: > > >> > > > commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java > > >> URL: > > >> > > > http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java?rev=1573561&r1=1573560&r2=1573561&view=diff > > >> > > >> > > > ============================================================================== > > >> --- > > >> > > > commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java > > >> (original) > > >> +++ > > >> > > > commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java > > >> Mon Mar 3 13:43:28 2014 > > >> @@ -623,7 +623,7 @@ public class DelegatingConnection<C exte > > >> // Statement's when it is closed. > > >> // DBCP-288. Not all the traced objects will be statements > > >> List<AbandonedTrace> traces = getTrace(); > > >> - if(traces != null) { > > >> + if(traces != null && traces.size() > 0) { > > >> Iterator<AbandonedTrace> traceIter = traces.iterator(); > > >> while (traceIter.hasNext()) { > > >> Object trace = traceIter.next(); > > >> > > >> > > >> > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [email protected] > > For additional commands, e-mail: [email protected] > > > > > -- E-Mail: [email protected] | [email protected] Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/> Spring Batch in Action <http://www.manning.com/templier/> Blog: http://garygregory.wordpress.com Home: http://garygregory.com/ Tweet! http://twitter.com/GaryGregory
