mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-17 21:46:36 +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"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
intRegex = regexp.MustCompile(`(u)?int([0-9]*)`)
|
||||||
|
)
|
||||||
|
|
||||||
func isKeyWord(arg string) bool {
|
func isKeyWord(arg string) bool {
|
||||||
switch arg {
|
switch arg {
|
||||||
case "break":
|
case "break":
|
||||||
|
|
@ -299,7 +303,7 @@ func bindBasicType(kind abi.Type) string {
|
||||||
case abi.AddressTy:
|
case abi.AddressTy:
|
||||||
return "common.Address"
|
return "common.Address"
|
||||||
case abi.IntTy, abi.UintTy:
|
case abi.IntTy, abi.UintTy:
|
||||||
parts := regexp.MustCompile(`(u)?int([0-9]*)`).FindStringSubmatch(kind.String())
|
parts := intRegex.FindStringSubmatch(kind.String())
|
||||||
switch parts[2] {
|
switch parts[2] {
|
||||||
case "8", "16", "32", "64":
|
case "8", "16", "32", "64":
|
||||||
return fmt.Sprintf("%sint%s", parts[1], parts[2])
|
return fmt.Sprintf("%sint%s", parts[1], parts[2])
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue