Replaced rune-slice parameters with string parameters in functions; avoids unnecessary conversion from strings to rune-slices
This commit is contained in:
7
misc.go
7
misc.go
@@ -22,11 +22,12 @@ func dotChars() []rune { // Returns all possible characters represented by the d
|
||||
}
|
||||
|
||||
// Returns true if str[idx] and str[idx-1] are separated by a word boundary.
|
||||
func isWordBoundary(str []rune, idx int) bool {
|
||||
func isWordBoundary(str string, idx int) bool {
|
||||
str_runes := []rune(str)
|
||||
wbounded := idx == 0 ||
|
||||
idx >= len(str)-1 ||
|
||||
(!slices.Contains(wordChars, str[idx-1]) && slices.Contains(wordChars, str[idx])) ||
|
||||
(slices.Contains(wordChars, str[idx-1]) && !slices.Contains(wordChars, str[idx]))
|
||||
(!slices.Contains(wordChars, str_runes[idx-1]) && slices.Contains(wordChars, str_runes[idx])) ||
|
||||
(slices.Contains(wordChars, str_runes[idx-1]) && !slices.Contains(wordChars, str_runes[idx]))
|
||||
return wbounded
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user