Skip to content
Myr

Code cleanup: remove unnecessary string conversions (#1642)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Christian Muehlhaeuser · committed by Junegunn Choi · parent a1260fe · Browse files · 2 files+3 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+3 added−3 removed

  • other:+3 added−3 removed

2 files+3 added−3 removed

modified:src/terminal.go+1 added-1 removed
1288 unmodified lines
12891290 for idx, item := range items {1291 tokens := Tokenize(item.AsString(stripAnsi), delimiter)1292 trans := Transform(tokens, ranges)1293 str := string(joinTokens(trans))1293 str := joinTokens(trans)1294 if delimiter.str != nil {1295 str = strings.TrimSuffix(str, *delimiter.str)1296 } else if delimiter.regex != nil {1297 delims := delimiter.regex.FindAllStringIndex(str, -1)
780 unmodified lines
modified:src/tokenizer_test.go+2 added-2 removed
71 unmodified lines
72 tokens := Tokenize(input, Delimiter{})73 {74 ranges := splitNth("1,2,3")75 tx := Transform(tokens, ranges)76 if string(joinTokens(tx)) != "abc: def: ghi: " {76 if joinTokens(tx) != "abc: def: ghi: " {77 t.Errorf("%s", tx)78 }79 }80 {
13 unmodified lines
94 tokens := Tokenize(input, delimiterRegexp(":"))95 {96 ranges := splitNth("1..2,3,2..,1")97 tx := Transform(tokens, ranges)98 if string(joinTokens(tx)) != " abc: def: ghi: def: ghi: jkl abc:" ||98 if joinTokens(tx) != " abc: def: ghi: def: ghi: jkl abc:" ||99 len(tx) != 4 ||100 tx[0].text.ToString() != " abc: def:" || tx[0].prefixLength != 0 ||101 tx[1].text.ToString() != " ghi:" || tx[1].prefixLength != 12 ||102 tx[2].text.ToString() != " def: ghi: jkl" || tx[2].prefixLength != 6 ||
10 unmodified lines