mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-12 01:41:36 +00:00
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.
This commit is contained in:
parent
0b35ad95f5
commit
c22d159bdf
1 changed files with 6 additions and 5 deletions
|
|
@ -18,6 +18,11 @@ package main
|
||||||
|
|
||||||
import "regexp"
|
import "regexp"
|
||||||
|
|
||||||
|
var (
|
||||||
|
eestTestMetadataPattern = `tests\/([^\/]+)\/([^\/]+)\/([^:]+)::([^[]+)\[fork_([^\-\]]+)-[^-]+-(.+)\]`
|
||||||
|
eestTestMetadataRegexp = regexp.MustCompile(eestTestMetadataPattern)
|
||||||
|
)
|
||||||
|
|
||||||
// testMetadata provides more granular access to the test information encoded
|
// testMetadata provides more granular access to the test information encoded
|
||||||
// within its filename by the execution spec test (EEST).
|
// within its filename by the execution spec test (EEST).
|
||||||
type testMetadata struct {
|
type testMetadata struct {
|
||||||
|
|
@ -31,11 +36,7 @@ type testMetadata struct {
|
||||||
// parseTestMetadata reads a test name and parses out more specific information
|
// parseTestMetadata reads a test name and parses out more specific information
|
||||||
// about the test.
|
// about the test.
|
||||||
func parseTestMetadata(s string) *testMetadata {
|
func parseTestMetadata(s string) *testMetadata {
|
||||||
var (
|
match := eestTestMetadataRegexp.FindStringSubmatch(s)
|
||||||
pattern = `tests\/([^\/]+)\/([^\/]+)\/([^:]+)::([^[]+)\[fork_([^-\]]+)-[^-]+-(.+)\]`
|
|
||||||
re = regexp.MustCompile(pattern)
|
|
||||||
)
|
|
||||||
match := re.FindStringSubmatch(s)
|
|
||||||
if len(match) == 0 {
|
if len(match) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue