Skip to content

Commit

Permalink
Merge pull request #60 from itchyny/fix-wrap-range-string
Browse files Browse the repository at this point in the history
Avoid rune slice allocation to range over string
  • Loading branch information
mattn committed Mar 21, 2022
2 parents a014e96 + 21148a0 commit 95547ad
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion runewidth.go
Expand Up @@ -218,7 +218,7 @@ func (c *Condition) Truncate(s string, w int, tail string) string {
func (c *Condition) Wrap(s string, w int) string {
width := 0
out := ""
for _, r := range []rune(s) {
for _, r := range s {
cw := c.RuneWidth(r)
if r == '\n' {
out += string(r)
Expand Down

0 comments on commit 95547ad

Please sign in to comment.