refactor: use the built-in max/min to simplify the code

Signed-off-by: wmypku <wmypku@outlook.com>
This commit is contained in:
wmypku
2025-08-26 16:50:03 +08:00
committed by elizaveta timofeeva
parent 8727e9cd91
commit 39daa172c3
2 changed files with 2 additions and 8 deletions

View File

@@ -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 {

View File

@@ -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]
}