Skip to content

Commit c6d161f

Browse files
Reduce trim cell value memory allocation for blank cells (qax-os#2096)
1 parent 5264285 commit c6d161f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

cell.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -510,14 +510,14 @@ func trimCellValue(value string, escape bool) (v string, ns xml.Attr) {
510510
if utf8.RuneCountInString(value) > TotalCellChars {
511511
value = string([]rune(value)[:TotalCellChars])
512512
}
513-
if escape {
513+
if escape && value != "" {
514514
var buf bytes.Buffer
515515
enc := xml.NewEncoder(&buf)
516516
_ = enc.EncodeToken(xml.CharData(value))
517-
enc.Flush()
517+
_ = enc.Flush()
518518
value = buf.String()
519519
}
520-
if len(value) > 0 {
520+
if value != "" {
521521
prefix, suffix := value[0], value[len(value)-1]
522522
for _, ascii := range []byte{9, 10, 13, 32} {
523523
if prefix == ascii || suffix == ascii {

0 commit comments

Comments
 (0)