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
|
@ -15,35 +15,35 @@ var makeStackItemTestCases = []struct {
|
|||
}{
|
||||
{
|
||||
input: int64(3),
|
||||
result: &BigInteger{value: big.NewInt(3)},
|
||||
result: (*BigInteger)(big.NewInt(3)),
|
||||
},
|
||||
{
|
||||
input: int16(3),
|
||||
result: &BigInteger{value: big.NewInt(3)},
|
||||
result: (*BigInteger)(big.NewInt(3)),
|
||||
},
|
||||
{
|
||||
input: 3,
|
||||
result: &BigInteger{value: big.NewInt(3)},
|
||||
result: (*BigInteger)(big.NewInt(3)),
|
||||
},
|
||||
{
|
||||
input: uint8(3),
|
||||
result: &BigInteger{value: big.NewInt(3)},
|
||||
result: (*BigInteger)(big.NewInt(3)),
|
||||
},
|
||||
{
|
||||
input: uint16(3),
|
||||
result: &BigInteger{value: big.NewInt(3)},
|
||||
result: (*BigInteger)(big.NewInt(3)),
|
||||
},
|
||||
{
|
||||
input: uint32(3),
|
||||
result: &BigInteger{value: big.NewInt(3)},
|
||||
result: (*BigInteger)(big.NewInt(3)),
|
||||
},
|
||||
{
|
||||
input: uint64(3),
|
||||
result: &BigInteger{value: big.NewInt(3)},
|
||||
result: (*BigInteger)(big.NewInt(3)),
|
||||
},
|
||||
{
|
||||
input: big.NewInt(3),
|
||||
result: &BigInteger{value: big.NewInt(3)},
|
||||
result: (*BigInteger)(big.NewInt(3)),
|
||||
},
|
||||
{
|
||||
input: []byte{1, 2, 3, 4},
|
||||
|
@ -70,12 +70,12 @@ var makeStackItemTestCases = []struct {
|
|||
result: Bool(false),
|
||||
},
|
||||
{
|
||||
input: []Item{&BigInteger{value: big.NewInt(3)}, &ByteArray{value: []byte{1, 2, 3}}},
|
||||
result: &Array{value: []Item{&BigInteger{value: big.NewInt(3)}, &ByteArray{value: []byte{1, 2, 3}}}},
|
||||
input: []Item{(*BigInteger)(big.NewInt(3)), &ByteArray{value: []byte{1, 2, 3}}},
|
||||
result: &Array{value: []Item{(*BigInteger)(big.NewInt(3)), &ByteArray{value: []byte{1, 2, 3}}}},
|
||||
},
|
||||
{
|
||||
input: []int{1, 2, 3},
|
||||
result: &Array{value: []Item{&BigInteger{value: big.NewInt(1)}, &BigInteger{value: big.NewInt(2)}, &BigInteger{value: big.NewInt(3)}}},
|
||||
result: &Array{value: []Item{(*BigInteger)(big.NewInt(1)), (*BigInteger)(big.NewInt(2)), (*BigInteger)(big.NewInt(3))}},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -281,18 +281,18 @@ var equalsTestCases = map[string][]struct {
|
|||
result: false,
|
||||
},
|
||||
{
|
||||
item1: NewArray([]Item{&BigInteger{big.NewInt(1)}, &BigInteger{big.NewInt(2)}, &BigInteger{big.NewInt(3)}}),
|
||||
item2: NewArray([]Item{&BigInteger{big.NewInt(1)}, &BigInteger{big.NewInt(2)}, &BigInteger{big.NewInt(3)}}),
|
||||
item1: NewArray([]Item{(*BigInteger)(big.NewInt(1)), (*BigInteger)(big.NewInt(2)), (*BigInteger)(big.NewInt(3))}),
|
||||
item2: NewArray([]Item{(*BigInteger)(big.NewInt(1)), (*BigInteger)(big.NewInt(2)), (*BigInteger)(big.NewInt(3))}),
|
||||
result: false,
|
||||
},
|
||||
{
|
||||
item1: NewArray([]Item{&BigInteger{big.NewInt(1)}}),
|
||||
item1: NewArray([]Item{(*BigInteger)(big.NewInt(1))}),
|
||||
item2: NewBigInteger(big.NewInt(1)),
|
||||
result: false,
|
||||
},
|
||||
{
|
||||
item1: NewArray([]Item{&BigInteger{big.NewInt(1)}, &BigInteger{big.NewInt(2)}, &BigInteger{big.NewInt(3)}}),
|
||||
item2: NewArray([]Item{&BigInteger{big.NewInt(1)}, &BigInteger{big.NewInt(2)}, &BigInteger{big.NewInt(4)}}),
|
||||
item1: NewArray([]Item{(*BigInteger)(big.NewInt(1)), (*BigInteger)(big.NewInt(2)), (*BigInteger)(big.NewInt(3))}),
|
||||
item2: NewArray([]Item{(*BigInteger)(big.NewInt(1)), (*BigInteger)(big.NewInt(2)), (*BigInteger)(big.NewInt(4))}),
|
||||
result: false,
|
||||
},
|
||||
},
|
||||
|
@ -441,7 +441,7 @@ var marshalJSONTestCases = []struct {
|
|||
result: []byte(`"010203"`),
|
||||
},
|
||||
{
|
||||
input: &Array{value: []Item{&BigInteger{value: big.NewInt(3)}, &ByteArray{value: []byte{1, 2, 3}}}},
|
||||
input: &Array{value: []Item{(*BigInteger)(big.NewInt(3)), &ByteArray{value: []byte{1, 2, 3}}}},
|
||||
result: []byte(`[3,"010203"]`),
|
||||
},
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue