Skip to content

Commit

Permalink
strcase: small optimizatiosn
Browse files Browse the repository at this point in the history
  • Loading branch information
charlievieth committed Feb 9, 2024
1 parent dc90e93 commit c844fec
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions strcase.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,9 @@ hasUnicode:
sr, s = rune(_lower[s[0]&0x7F]), s[1:]
} else {
r, size := utf8.DecodeRuneInString(s)
sr, s = caseFold(r), s[size:]
sr, s = r, s[size:]
}
if tr == sr || caseFold(tr) == sr {
if tr == sr || caseFold(tr) == caseFold(sr) {
continue
}
return false, len(s) == 0
Expand Down Expand Up @@ -1327,7 +1327,8 @@ func indexRuneCase(s string, r rune) int {
}
}
if n >= len(s) {
if string(r) == s {
// TODO: test if this is faster
if n == len(s) && string(r) == s {
return 0
}
return -1
Expand Down

0 comments on commit c844fec

Please sign in to comment.