Skip to content

Commit 4d9d728

Browse files
authored
accounts/abi: precompile regex (#32301)
1 parent 0814d99 commit 4d9d728

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

accounts/abi/abigen/bind.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ import (
3333
"github.com/ethereum/go-ethereum/log"
3434
)
3535

36+
var (
37+
intRegex = regexp.MustCompile(`(u)?int([0-9]*)`)
38+
)
39+
3640
func isKeyWord(arg string) bool {
3741
switch arg {
3842
case "break":
@@ -299,7 +303,7 @@ func bindBasicType(kind abi.Type) string {
299303
case abi.AddressTy:
300304
return "common.Address"
301305
case abi.IntTy, abi.UintTy:
302-
parts := regexp.MustCompile(`(u)?int([0-9]*)`).FindStringSubmatch(kind.String())
306+
parts := intRegex.FindStringSubmatch(kind.String())
303307
switch parts[2] {
304308
case "8", "16", "32", "64":
305309
return fmt.Sprintf("%sint%s", parts[1], parts[2])

0 commit comments

Comments
 (0)