mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-02-26 15:47:21 +00:00
accounts/abi: precompile regex (#32301)
This commit is contained in:
parent
0814d991ab
commit
4d9d72806c
1 changed files with 5 additions and 1 deletions
|
|
@ -33,6 +33,10 @@ import (
|
|||
"github.com/ethereum/go-ethereum/log"
|
||||
)
|
||||
|
||||
var (
|
||||
intRegex = regexp.MustCompile(`(u)?int([0-9]*)`)
|
||||
)
|
||||
|
||||
func isKeyWord(arg string) bool {
|
||||
switch arg {
|
||||
case "break":
|
||||
|
|
@ -299,7 +303,7 @@ func bindBasicType(kind abi.Type) string {
|
|||
case abi.AddressTy:
|
||||
return "common.Address"
|
||||
case abi.IntTy, abi.UintTy:
|
||||
parts := regexp.MustCompile(`(u)?int([0-9]*)`).FindStringSubmatch(kind.String())
|
||||
parts := intRegex.FindStringSubmatch(kind.String())
|
||||
switch parts[2] {
|
||||
case "8", "16", "32", "64":
|
||||
return fmt.Sprintf("%sint%s", parts[1], parts[2])
|
||||
|
|
|
|||
Loading…
Reference in a new issue