mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-08 04:20:17 +00:00
Moved regex to precompile
I don’t know why I put this in the hotpath. Signed-off-by: quobix <dave@quobix.com>
This commit is contained in:
@@ -713,10 +713,11 @@ func CheckEnumForDuplicates(seq []*yaml.Node) []*yaml.Node {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var whitespaceExp = regexp.MustCompile(`\n( +)`)
|
||||||
|
|
||||||
// DetermineWhitespaceLength will determine the length of the whitespace for a JSON or YAML file.
|
// DetermineWhitespaceLength will determine the length of the whitespace for a JSON or YAML file.
|
||||||
func DetermineWhitespaceLength(input string) int {
|
func DetermineWhitespaceLength(input string) int {
|
||||||
exp := regexp.MustCompile(`\n( +)`)
|
whiteSpace := whitespaceExp.FindAllStringSubmatch(input, -1)
|
||||||
whiteSpace := exp.FindAllStringSubmatch(input, -1)
|
|
||||||
var filtered []string
|
var filtered []string
|
||||||
for i := range whiteSpace {
|
for i := range whiteSpace {
|
||||||
filtered = append(filtered, whiteSpace[i][1])
|
filtered = append(filtered, whiteSpace[i][1])
|
||||||
|
|||||||
Reference in New Issue
Block a user