MCPcopy Index your code
hub / github.com/maruel/panicparse / trimCurlyBrackets

Function trimCurlyBrackets

stack/context.go:1190–1203  ·  view source on GitHub ↗

trimCurlyBrackets is the faster equivalent of bytes.TrimRight(bytes.TrimLeft(s, "{"), "}"). The function also returns the number of curly brackets trimmed from the left and the right.

(s []byte)

Source from the content-addressed store, hash-verified

1188// also returns the number of curly brackets trimmed from the
1189// left and the right.
1190func trimCurlyBrackets(s []byte) (int, []byte, int) {
1191 i, j := 0, len(s)
1192 for ; i < j; i++ {
1193 if s[i] != '{' {
1194 break
1195 }
1196 }
1197 for ; i < j; j-- {
1198 if s[j-1] != '}' {
1199 break
1200 }
1201 }
1202 return i, s[i:j], len(s) - j
1203}
1204
1205// unsafeString performs an unsafe conversion from a []byte to a string. The
1206// returned string will share the underlying memory with the []byte which thus

Callers 2

TestTrimCurlyBracketsFunction · 0.85
parseArgsFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestTrimCurlyBracketsFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…