Skip to content

Commit dda1e93

Browse files
committed
💄 compile regex one time
1 parent 2e6f9e5 commit dda1e93

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

‎main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ var (
6161
updateInterval = 1000
6262
)
6363

64+
var dataRegex = regexp.MustCompile(`(?m)^\s*(\S.*?)\s+(\d+)\s+(\d+\.\d+)\s+\d+\.\d+\s+`)
65+
6466
func setupUI() {
6567
appleSiliconModel := getSOCInfo()
6668
modelText = w.NewParagraph()
@@ -525,7 +527,6 @@ func updateProcessUI(processMetrics []ProcessMetrics) {
525527

526528
func parseProcessMetrics(powermetricsOutput string, processMetrics []ProcessMetrics) []ProcessMetrics {
527529
lines := strings.Split(powermetricsOutput, "\n")
528-
dataRegex := regexp.MustCompile(`(?m)^\s*(\S.*?)\s+(\d+)\s+(\d+\.\d+)\s+\d+\.\d+\s+`)
529530
seen := make(map[int]bool) // Map to track seen process IDs
530531
for _, line := range lines {
531532
matches := dataRegex.FindStringSubmatch(line)

0 commit comments

Comments
 (0)