Cache regex evaluation in i3.go
This commit is contained in:
@@ -154,18 +154,16 @@ func HasWindows(className string, instanceName string) bool {
|
||||
func FindWindowInstance(regexpStr string) bool {
|
||||
var found = false
|
||||
|
||||
f := func(key any, value any) bool { //nolint: revive
|
||||
keyStr := reflect.ValueOf(key).String()
|
||||
|
||||
re, err := regexp.Compile(regexpStr) // we do not want shit our pants and panic on
|
||||
// erroneous regexp, we want log it to stderr, that it.
|
||||
|
||||
re, err := regexp.Compile(regexpStr)
|
||||
if err != nil {
|
||||
log.Printf("Unable to perform regexp match: %s", err)
|
||||
|
||||
return true
|
||||
return false
|
||||
}
|
||||
|
||||
f := func(key any, value any) bool { //nolint: revive
|
||||
keyStr := reflect.ValueOf(key).String()
|
||||
|
||||
if re.Match([]byte(keyStr)) { //nolint:mirror
|
||||
found = true
|
||||
|
||||
@@ -185,18 +183,16 @@ func FindWindowInstance(regexpStr string) bool {
|
||||
func FindWindowClass(regexpStr string) bool {
|
||||
var found = false
|
||||
|
||||
f := func(key any, value any) bool { //nolint: revive
|
||||
keyStr := reflect.ValueOf(key).String()
|
||||
|
||||
re, err := regexp.Compile(regexpStr) // we do not want shit our pants and panic on
|
||||
// erroneous regexp, we want log it to stderr, that it.
|
||||
|
||||
re, err := regexp.Compile(regexpStr)
|
||||
if err != nil {
|
||||
log.Printf("Unable to perform regexp match: %s", err)
|
||||
|
||||
return true
|
||||
return false
|
||||
}
|
||||
|
||||
f := func(key any, value any) bool { //nolint: revive
|
||||
keyStr := reflect.ValueOf(key).String()
|
||||
|
||||
if re.Match([]byte(keyStr)) { //nolint:mirror
|
||||
found = true
|
||||
|
||||
|
||||
Reference in New Issue
Block a user