Merge c0326ecfab into d520615e53
				
					
				
			This commit is contained in:
		
						commit
						d859a34d99
					
				| 
						 | 
					@ -19,6 +19,7 @@ import (
 | 
				
			||||||
	"regexp"
 | 
						"regexp"
 | 
				
			||||||
	"sort"
 | 
						"sort"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
 | 
						"sync"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/******************************************************************************/
 | 
					/******************************************************************************/
 | 
				
			||||||
| 
						 | 
					@ -193,6 +194,7 @@ var (
 | 
				
			||||||
	layoutDowOfSpecificWeek   = `^(%value%)#([1-5])$`
 | 
						layoutDowOfSpecificWeek   = `^(%value%)#([1-5])$`
 | 
				
			||||||
	fieldFinder               = regexp.MustCompile(`\S+`)
 | 
						fieldFinder               = regexp.MustCompile(`\S+`)
 | 
				
			||||||
	entryFinder               = regexp.MustCompile(`[^,]+`)
 | 
						entryFinder               = regexp.MustCompile(`[^,]+`)
 | 
				
			||||||
 | 
						layoutRegexpLock          = sync.Mutex{}
 | 
				
			||||||
	layoutRegexp              = make(map[string]*regexp.Regexp)
 | 
						layoutRegexp              = make(map[string]*regexp.Regexp)
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -491,8 +493,14 @@ func makeLayoutRegexp(layout, value string) *regexp.Regexp {
 | 
				
			||||||
	layout = strings.Replace(layout, `%value%`, value, -1)
 | 
						layout = strings.Replace(layout, `%value%`, value, -1)
 | 
				
			||||||
	re := layoutRegexp[layout]
 | 
						re := layoutRegexp[layout]
 | 
				
			||||||
	if re == nil {
 | 
						if re == nil {
 | 
				
			||||||
		re = regexp.MustCompile(layout)
 | 
							// double check locking to fix issue: https://github.com/gorhill/cronexpr/issues/19
 | 
				
			||||||
		layoutRegexp[layout] = re
 | 
							layoutRegexpLock.Lock()
 | 
				
			||||||
 | 
							defer layoutRegexpLock.Unlock()
 | 
				
			||||||
 | 
							re = layoutRegexp[layout]
 | 
				
			||||||
 | 
							if re == nil {
 | 
				
			||||||
 | 
								re = regexp.MustCompile(layout)
 | 
				
			||||||
 | 
								layoutRegexp[layout] = re
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return re
 | 
						return re
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue