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 {
|
func FindWindowInstance(regexpStr string) bool {
|
||||||
var found = false
|
var found = false
|
||||||
|
|
||||||
f := func(key any, value any) bool { //nolint: revive
|
re, err := regexp.Compile(regexpStr)
|
||||||
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.
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Unable to perform regexp match: %s", err)
|
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
|
if re.Match([]byte(keyStr)) { //nolint:mirror
|
||||||
found = true
|
found = true
|
||||||
|
|
||||||
@@ -185,18 +183,16 @@ func FindWindowInstance(regexpStr string) bool {
|
|||||||
func FindWindowClass(regexpStr string) bool {
|
func FindWindowClass(regexpStr string) bool {
|
||||||
var found = false
|
var found = false
|
||||||
|
|
||||||
f := func(key any, value any) bool { //nolint: revive
|
re, err := regexp.Compile(regexpStr)
|
||||||
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.
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Unable to perform regexp match: %s", err)
|
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
|
if re.Match([]byte(keyStr)) { //nolint:mirror
|
||||||
found = true
|
found = true
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user