StringBuilder

From: Kevin Menard (kmenar..ervprise.com)
Date: Fri Dec 21 2007 - 10:01:04 EST

  • Next message: Andrus Adamchik: "Re: StringBuilder"

    Andrus,

    I noticed you changed some instances of StringBuffer to StringBuilder. This
    was one of those things I was considering to change throughout the code as
    well. I've been reluctant to do so, however, because I'm not sure if there
    are any places that we rely on the internal synchronization of StringBuffer.
    My hunch is "no", since it really doesn't gain you a whole lot and as such
    we likely use an external means of synchronization anyway.

    Do you know off-hand of any places that where we rely on internal
    synchronization for StringBuffers?

    -- 
    Kevin
    

    On 12/21/07 8:29 AM, "aadamchi..pache.org" <aadamchik@apache.org> wrote:

    > Author: aadamchik > Date: Fri Dec 21 05:29:05 2007 > New Revision: 606193 > > URL: http://svn.apache.org/viewvc?rev=606193&view=rev > Log: > generics > > Modified: > > cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apac > he/cayenne/query/NamedQuery.java > > cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apac > he/cayenne/query/ProcedureQueryMetadata.java > > cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apac > he/cayenne/query/SelectQueryMetadata.java > > Modified: > cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apac > he/cayenne/query/NamedQuery.java > URL: > http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpub > lished/src/main/java/org/apache/cayenne/query/NamedQuery.java?rev=606193&r1=60 > 6192&r2=606193&view=diff > ============================================================================== > --- > cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apac > he/cayenne/query/NamedQuery.java (original) > +++ > cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apac > he/cayenne/query/NamedQuery.java Fri Dec 21 05:29:05 2007 >.. -57,7 +57,7 @@ > public NamedQuery(String name, Map<String, ?> parameters) { > this.name = name; > > - // copy parameters map (among other things to make hessian > serilaization work). > + // copy parameters map (among other things to make hessian > serialization work). > if (parameters != null && !parameters.isEmpty()) { > this.parameters = new HashMap<String, Object>(parameters); > } > > Modified: > cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apac > he/cayenne/query/ProcedureQueryMetadata.java > URL: > http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpub > lished/src/main/java/org/apache/cayenne/query/ProcedureQueryMetadata.java?rev= > 606193&r1=606192&r2=606193&view=diff > ============================================================================== > --- > cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apac > he/cayenne/query/ProcedureQueryMetadata.java (original) > +++ > cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apac > he/cayenne/query/ProcedureQueryMetadata.java Fri Dec 21 05:29:05 2007 >.. -21,7 +21,6 @@ > > import java.util.ArrayList; > import java.util.Collections; > -import java.util.Iterator; > import java.util.List; > import java.util.Map; > >.. -75,20 +74,18 @@ > > // create a unique key based on procedure and parameters > > - StringBuffer key = new StringBuffer("proc:"); > + StringBuilder key = new StringBuilder("proc:"); > if (procedure != null) { > key.append(procedure.getName()); > } > > - Map parameters = query.getParameters(); > + Map<String, ?> parameters = query.getParameters(); > if (!parameters.isEmpty()) { > > - List keys = new ArrayList(parameters.keySet()); > + List<String> keys = new > ArrayList<String>(parameters.keySet()); > Collections.sort(keys); > > - Iterator it = keys.iterator(); > - while (it.hasNext()) { > - Object parameterKey = it.next(); > + for(String parameterKey : keys) { > > key.append('/').append(parameterKey).append('=').append( > parameters.get(parameterKey)); > } > > Modified: > cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apac > he/cayenne/query/SelectQueryMetadata.java > URL: > http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpub > lished/src/main/java/org/apache/cayenne/query/SelectQueryMetadata.java?rev=606 > 193&r1=606192&r2=606193&view=diff > ============================================================================== > --- > cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apac > he/cayenne/query/SelectQueryMetadata.java (original) > +++ > cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apac > he/cayenne/query/SelectQueryMetadata.java Fri Dec 21 05:29:05 2007 >.. -42,7 +42,7 @@ > // create a unique key based on entity, qualifier, ordering > and fetch > // limit > > - StringBuffer key = new StringBuffer(); > + StringBuilder key = new StringBuilder(); > > ObjEntity entity = getObjEntity(); > if (entity != null) { > >



    This archive was generated by hypermail 2.0.0 : Fri Dec 21 2007 - 10:01:37 EST