Skip to content

Commit 3495894

Browse files
authored
helper/schema: Compile valid field name regex once (#1062)
1 parent 6c09938 commit 3495894

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Diff for: helper/schema/schema.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -1093,9 +1093,10 @@ func checkKeysAgainstSchemaFlags(k string, keys []string, topSchemaMap schemaMap
10931093
return nil
10941094
}
10951095

1096+
var validFieldNameRe = regexp.MustCompile("^[a-z0-9_]+$")
1097+
10961098
func isValidFieldName(name string) bool {
1097-
re := regexp.MustCompile("^[a-z0-9_]+$")
1098-
return re.MatchString(name)
1099+
return validFieldNameRe.MatchString(name)
10991100
}
11001101

11011102
// resourceDiffer is an interface that is used by the private diff functions.

0 commit comments

Comments
 (0)