You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mc...@apache.org on 2011/11/03 10:24:21 UTC

svn commit: r1197014 - /commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTMethod.java

Author: mcucchiara
Date: Thu Nov  3 09:24:21 2011
New Revision: 1197014

URL: http://svn.apache.org/viewvc?rev=1197014&view=rev
Log:
OGNL-37 - Use StringBuilder instead of String concatenation with '+'.

Modified:
    commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTMethod.java

Modified: commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTMethod.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTMethod.java?rev=1197014&r1=1197013&r2=1197014&view=diff
==============================================================================
--- commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTMethod.java (original)
+++ commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTMethod.java Thu Nov  3 09:24:21 2011
@@ -138,7 +138,7 @@ public class ASTMethod
         }
 
         String post = "";
-        String result;
+        StringBuilder sourceStringBuilder;
         Method method;
 
         OgnlExpressionCompiler compiler = OgnlRuntime.getCompiler( context );
@@ -196,7 +196,7 @@ public class ASTMethod
                     "Javassist does not currently support varargs method calls" );
             }
 
-            result = "." + method.getName() + "(";
+            sourceStringBuilder = new StringBuilder().append( "." ).append( method.getName() ).append( "(" );
 
             if ( ( children != null ) && ( children.length > 0 ) )
             {
@@ -212,7 +212,7 @@ public class ASTMethod
                 {
                     if ( i > 0 )
                     {
-                        result = result + ", ";
+                        sourceStringBuilder.append( ", " );
                     }
 
                     Class prevType = context.getCurrentType();
@@ -235,7 +235,7 @@ public class ASTMethod
                                                                   ".class, true)" );
                     }
 
-                    result += parmString;
+                    sourceStringBuilder.append( parmString );
                 }
 
                 if ( prevCast != null )
@@ -260,18 +260,18 @@ public class ASTMethod
             throw OgnlOps.castToRuntime( t );
         }
 
-        result += ")" + post;
+        sourceStringBuilder.append( ")" ).append( post );
 
         if ( method.getReturnType() == void.class )
         {
-            coreExpression = result + ";";
+            coreExpression = sourceStringBuilder.toString() + ";";
             lastExpression = "null";
         }
 
         context.setCurrentType( method.getReturnType() );
         context.setCurrentAccessor( compiler.getSuperOrInterfaceClass( method, method.getDeclaringClass() ) );
 
-        return result;
+        return sourceStringBuilder.toString();
     }
 
     public String toSetSourceString( OgnlContext context, Object target )