MCPcopy Create free account
hub / github.com/dlclark/regexp2 / decodeString

Function decodeString

decode.go:61–73  ·  view source on GitHub ↗

decodeString converts s to []rune for the MatchString startAt<=0 path. Keep this as close as possible to a single UTF-8 walk so 4–30 byte matches stay cheap.

(s string, maxCachedLength int)

Source from the content-addressed store, hash-verified

59// Keep this as close as possible to a single UTF-8 walk so 4–30 byte
60// matches stay cheap.
61func decodeString(s string, maxCachedLength int) ([]rune, *[]rune) {
62 buf, pooled := pooledRuneBuffers.get(len(s), maxCachedLength)
63 if len(s) >= helpers.ASCIIScanMin {
64 n, _ := helpers.DecodeString(s, buf)
65 return buf[:n], pooled
66 }
67 n := 0
68 for _, ch := range s {
69 buf[n] = ch
70 n++
71 }
72 return buf[:n], pooled
73}
74
75// decodeStringInput decodes into exact-size storage a returned match can own.
76func (re *Regexp) decodeStringInput(s string, startAt int, pooled bool) decodedInput {

Callers 1

matchStringAtMethod · 0.85

Calls 2

DecodeStringFunction · 0.92
getMethod · 0.45

Tested by

no test coverage detected