Skip to content

Commit

Permalink
perf(textarea): amortize heap allocs in Value (charmbracelet#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
knz committed Aug 15, 2022
1 parent 9b67fb8 commit e72e4a1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions textarea/textarea.go
Expand Up @@ -271,13 +271,13 @@ func (m Model) Value() string {
return ""
}

var v string
var v strings.Builder
for _, l := range m.value {
v += string(l)
v += "\n"
v.WriteString(string(l))
v.WriteByte('\n')
}

return strings.TrimSuffix(v, "\n")
return strings.TrimSuffix(v.String(), "\n")
}

// Length returns the number of characters currently in the text input.
Expand Down

0 comments on commit e72e4a1

Please sign in to comment.