refactor: using slices.Contains to simplify the code

Signed-off-by: kindknow <iturf@sina.com>
This commit is contained in:
kindknow 2024-12-26 11:42:53 +08:00
parent 341647f186
commit f9d426b0a1

View file

@ -19,6 +19,7 @@ package native
import ( import (
"encoding/json" "encoding/json"
"math/big" "math/big"
"slices"
"strconv" "strconv"
"sync/atomic" "sync/atomic"
@ -75,12 +76,7 @@ func newFourByteTracer(ctx *tracers.Context, cfg json.RawMessage, chainConfig *p
// isPrecompiled returns whether the addr is a precompile. Logic borrowed from newJsTracer in eth/tracers/js/tracer.go // isPrecompiled returns whether the addr is a precompile. Logic borrowed from newJsTracer in eth/tracers/js/tracer.go
func (t *fourByteTracer) isPrecompiled(addr common.Address) bool { func (t *fourByteTracer) isPrecompiled(addr common.Address) bool {
for _, p := range t.activePrecompiles { return slices.Contains(t.activePrecompiles, addr)
if p == addr {
return true
}
}
return false
} }
// store saves the given identifier and datasize. // store saves the given identifier and datasize.