Documentation
¶
Overview ¶
Package lazyre holds a regular expression that is compiled the first time it is used, not when its package starts.
magpie is one binary, so every package's init runs on every launch, `magpie statusline` (run by Claude Code on each message) included. Hundreds of package-level regexp.MustCompile calls cost several MB and milliseconds there for patterns that launch never reaches. An RE has the methods of *regexp.Regexp that magpie calls; Regexp returns the compiled one. A bad pattern panics on first use, so TestAllCompile in each converted package compiles every one before release.
Index ¶
- func MustAll() int
- type RE
- func (r *RE) Expand(dst, template, src []byte, match []int) []byte
- func (r *RE) ExpandString(dst []byte, template string, src string, match []int) []byte
- func (r *RE) Find(b []byte) []byte
- func (r *RE) FindAll(b []byte, n int) [][]byte
- func (r *RE) FindAllIndex(b []byte, n int) [][]int
- func (r *RE) FindAllString(s string, n int) []string
- func (r *RE) FindAllStringIndex(s string, n int) [][]int
- func (r *RE) FindAllStringSubmatch(s string, n int) [][]string
- func (r *RE) FindAllStringSubmatchIndex(s string, n int) [][]int
- func (r *RE) FindAllSubmatch(b []byte, n int) [][][]byte
- func (r *RE) FindAllSubmatchIndex(b []byte, n int) [][]int
- func (r *RE) FindIndex(b []byte) []int
- func (r *RE) FindString(s string) string
- func (r *RE) FindStringIndex(s string) []int
- func (r *RE) FindStringSubmatch(s string) []string
- func (r *RE) FindStringSubmatchIndex(s string) []int
- func (r *RE) FindSubmatch(b []byte) [][]byte
- func (r *RE) FindSubmatchIndex(b []byte) []int
- func (r *RE) LiteralPrefix() (string, bool)
- func (r *RE) Match(b []byte) bool
- func (r *RE) MatchString(s string) bool
- func (r *RE) NumSubexp() int
- func (r *RE) Regexp() *regexp.Regexp
- func (r *RE) ReplaceAll(src, repl []byte) []byte
- func (r *RE) ReplaceAllFunc(src []byte, f func([]byte) []byte) []byte
- func (r *RE) ReplaceAllLiteral(src, repl []byte) []byte
- func (r *RE) ReplaceAllLiteralString(src, repl string) string
- func (r *RE) ReplaceAllString(src, repl string) string
- func (r *RE) ReplaceAllStringFunc(src string, f func(string) string) string
- func (r *RE) Split(s string, n int) []string
- func (r *RE) String() string
- func (r *RE) SubexpIndex(name string) int
- func (r *RE) SubexpNames() []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type RE ¶
type RE struct {
// contains filtered or unexported fields
}
RE is a regexp compiled on first use. Safe for concurrent use.