diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2016-08-14 01:53:06 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2016-08-14 02:19:29 +0900 |
commit | ddc7bb9064042a0d5da9546eaf6ff888dca63f0c (patch) | |
tree | 0eb63cd7c0cdc221332496ca2ddf3dcfe3cbb876 /src/util/util.go | |
parent | 1d4057c20907b7d263d6f2b8cb4350a024859dfe (diff) |
[perf] Optimize AWK-style tokenizer for --nth
Approx. 50% less memory footprint and 40% improvement in query time
Diffstat (limited to 'src/util/util.go')
-rw-r--r-- | src/util/util.go | 24 |
1 files changed, 0 insertions, 24 deletions
diff --git a/src/util/util.go b/src/util/util.go index 90cc28b4..a95340e7 100644 --- a/src/util/util.go +++ b/src/util/util.go @@ -83,30 +83,6 @@ func IsTty() bool { return int(C.isatty(C.int(os.Stdin.Fd()))) != 0 } -// TrimLen returns the length of trimmed rune array -func TrimLen(runes []rune) int { - var i int - for i = len(runes) - 1; i >= 0; i-- { - char := runes[i] - if char != ' ' && char != '\t' { - break - } - } - // Completely empty - if i < 0 { - return 0 - } - - var j int - for j = 0; j < len(runes); j++ { - char := runes[j] - if char != ' ' && char != '\t' { - break - } - } - return i - j + 1 -} - // ExecCommand executes the given command with $SHELL func ExecCommand(command string) *exec.Cmd { shell := os.Getenv("SHELL") |