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:44:11 UTC
[groovy] branch GROOVY_4_0_X updated: Trivial refactoring: extract variable
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch GROOVY_4_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/GROOVY_4_0_X by this push:
new a272a8d260 Trivial refactoring: extract variable
a272a8d260 is described below
commit a272a8d260929c949187b908058e9161be30d336
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sat Jul 16 17:42:44 2022 +0800
Trivial refactoring: extract variable
(cherry picked from commit fdb0c860e007a687c7ef402a78bccd74d091b4c1)
---
.../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()