mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-07 04:20:14 +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
|
||||
}
|
||||
|
||||
var whitespaceExp = regexp.MustCompile(`\n( +)`)
|
||||
|
||||
// DetermineWhitespaceLength will determine the length of the whitespace for a JSON or YAML file.
|
||||
func DetermineWhitespaceLength(input string) int {
|
||||
exp := regexp.MustCompile(`\n( +)`)
|
||||
whiteSpace := exp.FindAllStringSubmatch(input, -1)
|
||||
whiteSpace := whitespaceExp.FindAllStringSubmatch(input, -1)
|
||||
var filtered []string
|
||||
for i := range whiteSpace {
|
||||
filtered = append(filtered, whiteSpace[i][1])
|
||||
|
||||
Reference in New Issue
Block a user