mirror of
https://github.com/kubernetes/client-go.git
synced 2025-09-02 15:45:09 +00:00
Move regexp.MustCompile to global variable
Kubernetes-commit: 34747474659b26456c3615d9f79d014deacf505a
This commit is contained in:
committed by
Kubernetes Publisher
parent
be88969207
commit
302b3649ef
@@ -43,7 +43,11 @@ type Parser struct {
|
|||||||
width int
|
width int
|
||||||
}
|
}
|
||||||
|
|
||||||
var ErrSyntax = errors.New("invalid syntax")
|
var (
|
||||||
|
ErrSyntax = errors.New("invalid syntax")
|
||||||
|
dictKeyRex = regexp.MustCompile(`^'([^']*)'$`)
|
||||||
|
sliceOperatorRex = regexp.MustCompile(`^(-?[\d]*)(:-?[\d]*)?(:[\d]*)?$`)
|
||||||
|
)
|
||||||
|
|
||||||
// Parse parsed the given text and return a node Parser.
|
// Parse parsed the given text and return a node Parser.
|
||||||
// If an error is encountered, parsing stops and an empty
|
// If an error is encountered, parsing stops and an empty
|
||||||
@@ -283,8 +287,7 @@ Loop:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// dict key
|
// dict key
|
||||||
reg := regexp.MustCompile(`^'([^']*)'$`)
|
value := dictKeyRex.FindStringSubmatch(text)
|
||||||
value := reg.FindStringSubmatch(text)
|
|
||||||
if value != nil {
|
if value != nil {
|
||||||
parser, err := parseAction("arraydict", fmt.Sprintf(".%s", value[1]))
|
parser, err := parseAction("arraydict", fmt.Sprintf(".%s", value[1]))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -297,8 +300,7 @@ Loop:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//slice operator
|
//slice operator
|
||||||
reg = regexp.MustCompile(`^(-?[\d]*)(:-?[\d]*)?(:[\d]*)?$`)
|
value = sliceOperatorRex.FindStringSubmatch(text)
|
||||||
value = reg.FindStringSubmatch(text)
|
|
||||||
if value == nil {
|
if value == nil {
|
||||||
return fmt.Errorf("invalid array index %s", text)
|
return fmt.Errorf("invalid array index %s", text)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user