From 39daa172c324ddad9a995468674df4e683cc497a Mon Sep 17 00:00:00 2001 From: wmypku Date: Tue, 26 Aug 2025 16:50:03 +0800 Subject: [PATCH] refactor: use the built-in max/min to simplify the code Signed-off-by: wmypku --- bchain/baseparser.go | 5 +---- bchain/coins/eth/dataparser.go | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/bchain/baseparser.go b/bchain/baseparser.go index f1278cc3..9a7dcbea 100644 --- a/bchain/baseparser.go +++ b/bchain/baseparser.go @@ -47,10 +47,7 @@ func (p *BaseParser) AmountToBigInt(n common.JSONNumber) (big.Int, error) { var r big.Int s := string(n) i := strings.IndexByte(s, '.') - d := p.AmountDecimalPoint - if d > len(zeros) { - d = len(zeros) - } + d := min(p.AmountDecimalPoint, len(zeros)) if i == -1 { s = s + zeros[:d] } else { diff --git a/bchain/coins/eth/dataparser.go b/bchain/coins/eth/dataparser.go index 81826926..1d06fdda 100644 --- a/bchain/coins/eth/dataparser.go +++ b/bchain/coins/eth/dataparser.go @@ -51,10 +51,7 @@ func parseSimpleStringProperty(data string) string { // allow string properties as UTF-8 data b, err := hex.DecodeString(data) if err == nil { - i := bytes.Index(b, []byte{0}) - if i > 32 { - i = 32 - } + i := min(bytes.Index(b, []byte{0}), 32) if i > 0 { b = b[:i] }