mirror of
https://github.com/golang/go
synced 2024-11-24 23:27:57 -07:00
strings.TrimSpace micro-optimization
strings.TrimSpace string's end final trimming should use more specific TrimRightFunc instead of common TrimFunc (because start has already trimmed before)
This commit is contained in:
parent
3f9ec83b10
commit
040607a831
@ -884,7 +884,8 @@ func TrimSpace(s string) string {
|
||||
for ; stop > start; stop-- {
|
||||
c := s[stop-1]
|
||||
if c >= utf8.RuneSelf {
|
||||
return TrimFunc(s[start:stop], unicode.IsSpace)
|
||||
// start has been already trimmed above, should trim end only
|
||||
return TrimRightFunc(s[start:stop], unicode.IsSpace)
|
||||
}
|
||||
if asciiSpace[c] == 0 {
|
||||
break
|
||||
|
Loading…
Reference in New Issue
Block a user