You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2022/07/16 09:43:04 UTC

[groovy] branch master updated: Trivial refactoring: extract variable

This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
     new fdb0c860e0 Trivial refactoring: extract variable
fdb0c860e0 is described below

commit fdb0c860e007a687c7ef402a78bccd74d091b4c1
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sat Jul 16 17:42:44 2022 +0800

    Trivial refactoring: extract variable
---
 .../groovy/ginq/provider/collection/runtime/AsciiTableMaker.groovy | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/subprojects/groovy-ginq/src/main/groovy/org/apache/groovy/ginq/provider/collection/runtime/AsciiTableMaker.groovy b/subprojects/groovy-ginq/src/main/groovy/org/apache/groovy/ginq/provider/collection/runtime/AsciiTableMaker.groovy
index 22ec00764a..cffd3dc6cc 100644
--- a/subprojects/groovy-ginq/src/main/groovy/org/apache/groovy/ginq/provider/collection/runtime/AsciiTableMaker.groovy
+++ b/subprojects/groovy-ginq/src/main/groovy/org/apache/groovy/ginq/provider/collection/runtime/AsciiTableMaker.groovy
@@ -70,7 +70,7 @@ class AsciiTableMaker {
      * @since 4.0.0
      */
     static String makeAsciiTable(List<String[]> table, int maxWidth, boolean leftJustifiedRows) {
-        StringBuilder result = new StringBuilder()
+        StringBuilder result = new StringBuilder(512)
 
         if (0 == maxWidth) maxWidth = DEFAULT_MAX_WIDTH
 
@@ -140,13 +140,14 @@ class AsciiTableMaker {
 
         // Print table
         result.append(line)
+        final fmt = formatString.toString()
         Arrays.stream(finalTable)
                 .limit(1)
-                .forEach(a -> result.append(String.format(formatString.toString(), (Object[]) a)))
+                .forEach(a -> result.append(String.format(fmt, (Object[]) a)))
         result.append(line)
 
         range(1, finalTable.length)
-                .forEach(i -> result.append(String.format(formatString.toString(), (Object[]) finalTable[i])))
+                .forEach(i -> result.append(String.format(fmt, (Object[]) finalTable[i])))
         result.append(line)
 
         return result.toString()