From a335c07a451866372954c19691bd3be50b5309d6 Mon Sep 17 00:00:00 2001 From: Zac Spitzer Date: Thu, 14 Nov 2024 15:34:11 +0100 Subject: [PATCH] LDEV-5158 set initial size for query.toString() stringbuilder --- core/src/main/java/lucee/runtime/type/QueryImpl.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/lucee/runtime/type/QueryImpl.java b/core/src/main/java/lucee/runtime/type/QueryImpl.java index c31cd74a96..a66ca518fa 100755 --- a/core/src/main/java/lucee/runtime/type/QueryImpl.java +++ b/core/src/main/java/lucee/runtime/type/QueryImpl.java @@ -1594,8 +1594,15 @@ public QueryColumn getColumn(Collection.Key key, QueryColumn defaultValue) { @Override public String toString() { Collection.Key[] keys = keys(); + // each column is padded out 23 chars + 1 char, 3 header rows, query / recordcount... better initial size + int size = ((( 23 * (2 * keys.length)) + 1) * (getRecordcount() + 3)) + 35; + if (sql != null ) size = size + sql.getSQLString().length() + 55; + if (exeTime > 0) size = size + 25 + 55; - StringBuffer sb = new StringBuffer(); + //lucee.aprint.o(""); + //lucee.aprint.o(size); + + StringBuffer sb = new StringBuffer(size); sb.append("| Query: ").append(this.name).append("\tRecordCount: ").append(getRecordcount()).append('\n');