mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-14 02:57:52 +08:00
ee62608e88
Also remove unused functions. There were two (correct) implementations of deciding whether a string has another string as a subsequence; keep the more performant one.
21 lines
398 B
Go
21 lines
398 B
Go
package strutil
|
|
|
|
import (
|
|
"strings"
|
|
)
|
|
|
|
// FindFirstEOL returns the index of the first '\n'. When there is no '\n', the
|
|
// length of s is returned.
|
|
func FindFirstEOL(s string) int {
|
|
eol := strings.IndexRune(s, '\n')
|
|
if eol == -1 {
|
|
eol = len(s)
|
|
}
|
|
return eol
|
|
}
|
|
|
|
// FindLastSOL returns an index just after the last '\n'.
|
|
func FindLastSOL(s string) int {
|
|
return strings.LastIndex(s, "\n") + 1
|
|
}
|