mirror of
https://github.com/containerd/containerd.git
synced 2026-06-24 08:48:48 +00:00
use lazyregexp to compile regexes on first use
- internal/cri/bandwidth: use lazyregexp to compile regexes on first use - pkg/identifiers: use lazyregexp to compile regexes on first use - pkg/progress: use lazyregexp to compile regexes on first use - pkg/reference: use lazyregexp to compile regexes on first use - pkg/sys: use lazyregexp to compile regexes on first use Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -40,19 +40,19 @@ import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"net"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/utils/exec"
|
||||
|
||||
"k8s.io/klog/v2"
|
||||
"github.com/containerd/containerd/v2/internal/lazyregexp"
|
||||
)
|
||||
|
||||
var (
|
||||
classShowMatcher = regexp.MustCompile(`class htb (1:\d+)`)
|
||||
classAndHandleMatcher = regexp.MustCompile(`filter parent 1:.*fh (\d+::\d+).*flowid (\d+:\d+)`)
|
||||
classShowMatcher = lazyregexp.New(`class htb (1:\d+)`)
|
||||
classAndHandleMatcher = lazyregexp.New(`filter parent 1:.*fh (\d+::\d+).*flowid (\d+:\d+)`)
|
||||
)
|
||||
|
||||
// tcShaper provides an implementation of the Shaper interface on Linux using the 'tc' tool.
|
||||
|
||||
@@ -26,8 +26,8 @@ package identifiers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
|
||||
"github.com/containerd/containerd/v2/internal/lazyregexp"
|
||||
"github.com/containerd/errdefs"
|
||||
)
|
||||
|
||||
@@ -39,7 +39,7 @@ const (
|
||||
|
||||
var (
|
||||
// identifierRe defines the pattern for valid identifiers.
|
||||
identifierRe = regexp.MustCompile(reAnchor(alphanum + reGroup(separators+reGroup(alphanum)) + "*"))
|
||||
identifierRe = lazyregexp.New(reAnchor(alphanum + reGroup(separators+reGroup(alphanum)) + "*"))
|
||||
)
|
||||
|
||||
// Validate returns nil if the string s is a valid identifier.
|
||||
|
||||
@@ -21,14 +21,14 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/containerd/console"
|
||||
"github.com/containerd/containerd/v2/internal/lazyregexp"
|
||||
)
|
||||
|
||||
var (
|
||||
regexCleanLine = regexp.MustCompile("\x1b\\[[0-9]+m[\x1b]?")
|
||||
regexCleanLine = lazyregexp.New("\x1b\\[[0-9]+m[\x1b]?")
|
||||
)
|
||||
|
||||
// Writer buffers writes until flush, at which time the last screen is cleared
|
||||
|
||||
@@ -20,9 +20,9 @@ import (
|
||||
"errors"
|
||||
"net/url"
|
||||
"path"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/containerd/containerd/v2/internal/lazyregexp"
|
||||
digest "github.com/opencontainers/go-digest"
|
||||
)
|
||||
|
||||
@@ -80,7 +80,7 @@ type Spec struct {
|
||||
Object string
|
||||
}
|
||||
|
||||
var splitRe = regexp.MustCompile(`[:@]`)
|
||||
var splitRe = lazyregexp.New(`[:@]`)
|
||||
|
||||
// Parse parses the string into a structured ref.
|
||||
func Parse(s string) (Spec, error) {
|
||||
|
||||
@@ -18,11 +18,12 @@ package sys
|
||||
|
||||
import (
|
||||
"os"
|
||||
"regexp"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
|
||||
"github.com/containerd/containerd/v2/internal/lazyregexp"
|
||||
)
|
||||
|
||||
// SddlAdministratorsLocalSystem is local administrators plus NT AUTHORITY\System.
|
||||
@@ -31,7 +32,7 @@ const SddlAdministratorsLocalSystem = "D:P(A;OICI;GA;;;BA)(A;OICI;GA;;;SY)"
|
||||
// volumePath is a regular expression to check if a path is a Windows
|
||||
// volume path (e.g., "\\?\Volume{4c1b02c1-d990-11dc-99ae-806e6f6e6963}"
|
||||
// or "\\?\Volume{4c1b02c1-d990-11dc-99ae-806e6f6e6963}\").
|
||||
var volumePath = regexp.MustCompile(`^\\\\\?\\Volume{[a-z0-9-]+}\\?$`)
|
||||
var volumePath = lazyregexp.New(`^\\\\\?\\Volume{[a-z0-9-]+}\\?$`)
|
||||
|
||||
// MkdirAllWithACL is a custom version of os.MkdirAll modified for use on Windows
|
||||
// so that it is both volume path aware, and to create a directory
|
||||
|
||||
Reference in New Issue
Block a user