perf(textarea): amortize heap allocs in Value (#212)

This commit is contained in:
kena 2022-08-15 16:24:54 +02:00 committed by GitHub
parent 9b67fb8724
commit e72e4a190b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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.