From c6d161fc76e6165cc95693a1c50696dac7faa74b Mon Sep 17 00:00:00 2001 From: Artur Chopikian Date: Sun, 2 Mar 2025 05:24:49 +0200 Subject: [PATCH] Reduce trim cell value memory allocation for blank cells (#2096) --- cell.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cell.go b/cell.go index fe204d66cb..35f64854c8 100644 --- a/cell.go +++ b/cell.go @@ -510,14 +510,14 @@ func trimCellValue(value string, escape bool) (v string, ns xml.Attr) { if utf8.RuneCountInString(value) > TotalCellChars { value = string([]rune(value)[:TotalCellChars]) } - if escape { + if escape && value != "" { var buf bytes.Buffer enc := xml.NewEncoder(&buf) _ = enc.EncodeToken(xml.CharData(value)) - enc.Flush() + _ = enc.Flush() value = buf.String() } - if len(value) > 0 { + if value != "" { prefix, suffix := value[0], value[len(value)-1] for _, ascii := range []byte{9, 10, 13, 32} { if prefix == ascii || suffix == ascii {