[perf] Optimize AWK-style tokenizer for --nth

Approx. 50% less memory footprint and 40% improvement in query time
This commit is contained in:
Junegunn Choi committed 2016-08-14 02:19:29 +09:00
1 parent 1d4057c209
commit ddc7bb9064
5 files changed
+57 -59

No files matched your search

-20
View File
@@ -20,23 +20,3 @@ func TestContrain(t *testing.T) {
t.Error("Expected", 3)
}
}
func TestTrimLen(t *testing.T) {
check := func(str string, exp int) {
trimmed := TrimLen([]rune(str))
if trimmed != exp {
t.Errorf("Invalid TrimLen result for '%s': %d (expected %d)",
str, trimmed, exp)
}
}
check("hello", 5)
check("hello ", 5)
check("hello ", 5)
check(" hello", 5)
check(" hello", 5)
check(" hello ", 5)
check(" hello ", 5)
check("h o", 5)
check(" h o ", 5)
check(" ", 0)
}