mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-07 15:07:36 +00:00
stackitem: make BigInteger
alias to big.Int
Remove one indirection step. `` name old time/op new time/op delta MakeInt-8 79.7ns ± 8% 56.2ns ± 8% -29.44% (p=0.000 n=10+10) name old alloc/op new alloc/op delta MakeInt-8 48.0B ± 0% 40.0B ± 0% -16.67% (p=0.000 n=10+10) name old allocs/op new allocs/op delta MakeInt-8 3.00 ± 0% 2.00 ± 0% -33.33% (p=0.000 n=10+10) ``` Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
cff8b1c24e
commit
a5516e8c96
3 changed files with 42 additions and 61 deletions
|
@ -110,10 +110,10 @@ func toJSON(data []byte, seen map[Item]sliceNoPointer, item Item) ([]byte, error
|
|||
data = append(data, '}')
|
||||
seen[item] = sliceNoPointer{start, len(data)}
|
||||
case *BigInteger:
|
||||
if it.value.CmpAbs(big.NewInt(MaxAllowedInteger)) == 1 {
|
||||
if it.Big().CmpAbs(big.NewInt(MaxAllowedInteger)) == 1 {
|
||||
return nil, fmt.Errorf("%w (MaxAllowedInteger)", ErrInvalidValue)
|
||||
}
|
||||
data = append(data, it.value.String()...)
|
||||
data = append(data, it.Big().String()...)
|
||||
case *ByteArray, *Buffer:
|
||||
raw, err := itemToJSONString(it)
|
||||
if err != nil {
|
||||
|
@ -293,7 +293,7 @@ func toJSONWithTypes(item Item, seen map[Item]bool) (interface{}, error) {
|
|||
case *Buffer, *ByteArray:
|
||||
value = base64.StdEncoding.EncodeToString(it.Value().([]byte))
|
||||
case *BigInteger:
|
||||
value = it.value.String()
|
||||
value = it.Big().String()
|
||||
case *Map:
|
||||
if seen[item] {
|
||||
return "", ErrRecursive
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue