lazyre

package
v0.1.4607 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustAll

func MustAll() int

MustAll compiles every RE made so far and returns how many there are, so a test fails on a bad pattern.

Types

type RE

type RE struct {
	// contains filtered or unexported fields
}

RE is a regexp compiled on first use. Safe for concurrent use.

func New

func New(src string) *RE

New returns an RE for src. It does not compile it.

func Of

func Of(re *regexp.Regexp) *RE

Of wraps an expression already compiled, for a field that holds both kinds.

func (*RE) Expand

func (r *RE) Expand(dst, template, src []byte, match []int) []byte

func (*RE) ExpandString

func (r *RE) ExpandString(dst []byte, template string, src string, match []int) []byte

func (*RE) Find

func (r *RE) Find(b []byte) []byte

func (*RE) FindAll

func (r *RE) FindAll(b []byte, n int) [][]byte

func (*RE) FindAllIndex

func (r *RE) FindAllIndex(b []byte, n int) [][]int

func (*RE) FindAllString

func (r *RE) FindAllString(s string, n int) []string

func (*RE) FindAllStringIndex

func (r *RE) FindAllStringIndex(s string, n int) [][]int

func (*RE) FindAllStringSubmatch

func (r *RE) FindAllStringSubmatch(s string, n int) [][]string

func (*RE) FindAllStringSubmatchIndex

func (r *RE) FindAllStringSubmatchIndex(s string, n int) [][]int

func (*RE) FindAllSubmatch

func (r *RE) FindAllSubmatch(b []byte, n int) [][][]byte

func (*RE) FindAllSubmatchIndex

func (r *RE) FindAllSubmatchIndex(b []byte, n int) [][]int

func (*RE) FindIndex

func (r *RE) FindIndex(b []byte) []int

func (*RE) FindString

func (r *RE) FindString(s string) string

func (*RE) FindStringIndex

func (r *RE) FindStringIndex(s string) []int

func (*RE) FindStringSubmatch

func (r *RE) FindStringSubmatch(s string) []string

func (*RE) FindStringSubmatchIndex

func (r *RE) FindStringSubmatchIndex(s string) []int

func (*RE) FindSubmatch

func (r *RE) FindSubmatch(b []byte) [][]byte

func (*RE) FindSubmatchIndex

func (r *RE) FindSubmatchIndex(b []byte) []int

func (*RE) LiteralPrefix

func (r *RE) LiteralPrefix() (string, bool)

func (*RE) Match

func (r *RE) Match(b []byte) bool

func (*RE) MatchString

func (r *RE) MatchString(s string) bool

func (*RE) NumSubexp

func (r *RE) NumSubexp() int

func (*RE) Regexp

func (r *RE) Regexp() *regexp.Regexp

Regexp returns the compiled expression, compiling it the first time.

func (*RE) ReplaceAll

func (r *RE) ReplaceAll(src, repl []byte) []byte

func (*RE) ReplaceAllFunc

func (r *RE) ReplaceAllFunc(src []byte, f func([]byte) []byte) []byte

func (*RE) ReplaceAllLiteral

func (r *RE) ReplaceAllLiteral(src, repl []byte) []byte

func (*RE) ReplaceAllLiteralString

func (r *RE) ReplaceAllLiteralString(src, repl string) string

func (*RE) ReplaceAllString

func (r *RE) ReplaceAllString(src, repl string) string

func (*RE) ReplaceAllStringFunc

func (r *RE) ReplaceAllStringFunc(src string, f func(string) string) string

func (*RE) Split

func (r *RE) Split(s string, n int) []string

func (*RE) String

func (r *RE) String() string

func (*RE) SubexpIndex

func (r *RE) SubexpIndex(name string) int

func (*RE) SubexpNames

func (r *RE) SubexpNames() []string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL