cmd/compile: teach prove.go that {strings|bytes}.Index* return value in the range [-1 .. len(s)) #25862
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Performance
Milestone
The issue
Currently prove.go doesn't know that functions like
strings.Index*
always return value in the range[-1 .. len(s))
wheres
- input string / byte slice. So it emits unnecessary bounds checks in the following code:go tip compiler generates the following assembly code for
nextSpace
:The solution
{strings|bytes}.Index*
return value in the range[-1 .. len(s))
&s[0] + len(s) - n
doesn't exceed max word value if0 <= n < len(s)
This should improve performance of various parsers for text-based messages (json, xml, html, http, etc.)
The text was updated successfully, but these errors were encountered: