mirror of
https://github.com/trezor/blockbook.git
synced 2026-02-20 00:51:39 +01:00
refactor: use the built-in max/min to simplify the code
Signed-off-by: wmypku <wmypku@outlook.com>
This commit is contained in:
committed by
elizaveta timofeeva
parent
8727e9cd91
commit
39daa172c3
@@ -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 {
|
||||
|
||||
@@ -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]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user