Skip to content

Commit

Permalink
Reduce trim cell value memory allocation for blank cells (#2096)
Browse files Browse the repository at this point in the history
  • Loading branch information
artur-chopikian authored Mar 2, 2025
1 parent 5264285 commit c6d161f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cell.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit c6d161f

Please sign in to comment.