all: use a faster vendored regexp/syntax/Regexp.String (#753)
We replace all calls to Regexp.String with a vendored version which is
faster.
go1.22 introduced a commit which "minimizes" the string returned by
Regexp.String(). Part of what it does is run enumerate through literals
runes in your string to see calculate flags related to unicode and case
sensitivity. This can be quite slow, but is made worse by the fact we
call it per shard per regexp in your query.Q to construct the matchtree.
Currently Regexp.String() represents 40% of CPU time on sourcegraph.com.
Before go1.22 it was ~0%.
Note: This is a temporary change to resolve the issue. I have a deeper
change to make this less clumsy.
Note: In one place we remove the use of string by relying on
Regexp.Equal instead.
Test Plan: go test