commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Benson <gudnabr...@gmail.com>
Subject Re: svn commit: r1102197 - in /commons/sandbox/digester3/trunk/src: examples/api/addressbook/ examples/api/dbinsert/ examples/api/document-markup/ examples/plugins/pipeline/ examples/xmlrules/addressbook/ main/java/org/apache/commons/digester3/ main/
Date Thu, 12 May 2011 12:50:47 GMT
On Thu, May 12, 2011 at 5:04 AM, sebb <sebbaz@gmail.com> wrote:
> On 12 May 2011 09:07,  <simonetripodi@apache.org> wrote:
>> Author: simonetripodi
>> Date: Thu May 12 08:07:43 2011
>> New Revision: 1102197
>>
>> URL: http://svn.apache.org/viewvc?rev=1102197&view=rev
>> Log:
>> since Digester is not thread safe, better switching from StringBuffer to StringBuilder
that's faster
>>
>> Modified:
>>    commons/sandbox/digester3/trunk/src/examples/api/addressbook/Address.java
>>    commons/sandbox/digester3/trunk/src/examples/api/dbinsert/RowInserterRule.java
>>    commons/sandbox/digester3/trunk/src/examples/api/document-markup/MarkupDigester.java
>>    commons/sandbox/digester3/trunk/src/examples/plugins/pipeline/SubstituteTransform.java
>>    commons/sandbox/digester3/trunk/src/examples/xmlrules/addressbook/Address.java
>>    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/BeanPropertySetterRule.java
>>    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/CallMethodRule.java
>>    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/CallParamRule.java
>>    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/Digester.java
>>    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/FactoryCreateRule.java
>>    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/NodeCreateRule.java
>>    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/ObjectCreateRule.java
>>    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/ObjectParamRule.java
>>    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/PathCallParamRule.java
>>    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetNestedPropertiesRule.java
>>    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetNextRule.java
>>    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetPropertiesRule.java
>>    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetPropertyRule.java
>>    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetRootRule.java
>>    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetTopRule.java
>>    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/xmlrules/DigesterRuleParser.java
>>    commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/Address.java
>>    commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/Box.java
>>    commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/CallMethodRuleTestCase.java
>>    commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/Employee.java
>>    commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/LocationTrackerTestCase.java
>>    commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/ObjectParamRuleTestCase.java
>>    commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/OverlappingCallMethodRuleTestCase.java
>>    commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/SimpleTestBean.java
>>    commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestXmlRuleInfo.java
>>
>> Modified: commons/sandbox/digester3/trunk/src/examples/api/addressbook/Address.java
>> URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/examples/api/addressbook/Address.java?rev=1102197&r1=1102196&r2=1102197&view=diff
>> ==============================================================================
>> --- commons/sandbox/digester3/trunk/src/examples/api/addressbook/Address.java (original)
>> +++ commons/sandbox/digester3/trunk/src/examples/api/addressbook/Address.java Thu
May 12 08:07:43 2011
>> @@ -30,7 +30,7 @@ public class Address {
>>     private String country;
>>
>>     public String toString() {
>> -        StringBuffer sb = new StringBuffer();
>> +        StringBuilder sb = new StringBuilder();
>>         sb.append( " address (type "+ type + ")\n");
>>         sb.append( "       " + street + "\n");
>>         sb.append( "       " + city + " " + state + " " + zip + "\n");
>> @@ -39,7 +39,7 @@ public class Address {
>>     }
>>
>
> BTW, thread-safety is not an issue for local variables (unless you
> publish them e.g. by returning them).
> In this case, the StringBuilder is converted to a thread-safe String
> before publication.
>

I think Simo's actual meaning was along the lines of the more verbose
"since all the String building takes place locally and there is no
need for thread-safety on the builder object, switch to the faster
StringBuilder per that class's explicitly stated purpose in being."

Matt

> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message