From c22d159bdfbc1b2764c688a9de239525497bbdf0 Mon Sep 17 00:00:00 2001 From: Daniel Liu <139250065@qq.com> Date: Thu, 16 Apr 2026 14:13:21 +0800 Subject: [PATCH] cmd/evm: move parseTestMetadata regexp to package-level var for efficiency `parseTestMetadata` recompiles the regexp on every call (and it is invoked for every result printed). This adds avoidable overhead for large test runs. Move the compiled regexp to a package-level var and reuse it. --- cmd/evm/eest.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cmd/evm/eest.go b/cmd/evm/eest.go index 4cda2fc517..57ad32fdb2 100644 --- a/cmd/evm/eest.go +++ b/cmd/evm/eest.go @@ -18,6 +18,11 @@ package main import "regexp" +var ( + eestTestMetadataPattern = `tests\/([^\/]+)\/([^\/]+)\/([^:]+)::([^[]+)\[fork_([^\-\]]+)-[^-]+-(.+)\]` + eestTestMetadataRegexp = regexp.MustCompile(eestTestMetadataPattern) +) + // testMetadata provides more granular access to the test information encoded // within its filename by the execution spec test (EEST). type testMetadata struct { @@ -31,11 +36,7 @@ type testMetadata struct { // parseTestMetadata reads a test name and parses out more specific information // about the test. func parseTestMetadata(s string) *testMetadata { - var ( - pattern = `tests\/([^\/]+)\/([^\/]+)\/([^:]+)::([^[]+)\[fork_([^-\]]+)-[^-]+-(.+)\]` - re = regexp.MustCompile(pattern) - ) - match := re.FindStringSubmatch(s) + match := eestTestMetadataRegexp.FindStringSubmatch(s) if len(match) == 0 { return nil }