Skip to content

Commit b7fd2a9

Browse files
perf: get rid of Encode calls on primitives
1 parent b4385c7 commit b7fd2a9

50 files changed

Lines changed: 100 additions & 72 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

programs/compute-budget/RequestHeapFrame.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package computebudget
1616

1717
import (
18+
"encoding/binary"
1819
"errors"
1920

2021
ag_binary "github.com/gagliardetto/solana-go/binary"
@@ -97,7 +98,7 @@ func (inst *RequestHeapFrame) EncodeToTree(parent ag_treeout.Branches) {
9798

9899
func (obj RequestHeapFrame) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) {
99100
// Serialize `HeapSize` param:
100-
err = encoder.Encode(obj.HeapSize)
101+
err = encoder.WriteUint32(obj.HeapSize, binary.LittleEndian)
101102
if err != nil {
102103
return err
103104
}

programs/compute-budget/RequestUnitsDeprecated.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package computebudget
1616

1717
import (
18+
"encoding/binary"
1819
"errors"
1920

2021
ag_binary "github.com/gagliardetto/solana-go/binary"
@@ -109,13 +110,13 @@ func (inst *RequestUnitsDeprecated) EncodeToTree(parent ag_treeout.Branches) {
109110

110111
func (obj RequestUnitsDeprecated) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) {
111112
// Serialize `Units` param:
112-
err = encoder.Encode(obj.Units)
113+
err = encoder.WriteUint32(obj.Units, binary.LittleEndian)
113114
if err != nil {
114115
return err
115116
}
116117

117118
// Serialize `AdditionalFee` param:
118-
err = encoder.Encode(obj.AdditionalFee)
119+
err = encoder.WriteUint32(obj.AdditionalFee, binary.LittleEndian)
119120
if err != nil {
120121
return err
121122
}

programs/compute-budget/SetComputeUnitLimit.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package computebudget
1616

1717
import (
18+
"encoding/binary"
1819
"errors"
1920

2021
ag_binary "github.com/gagliardetto/solana-go/binary"
@@ -97,7 +98,7 @@ func (inst *SetComputeUnitLimit) EncodeToTree(parent ag_treeout.Branches) {
9798

9899
func (obj SetComputeUnitLimit) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) {
99100
// Serialize `Units` param:
100-
err = encoder.Encode(obj.Units)
101+
err = encoder.WriteUint32(obj.Units, binary.LittleEndian)
101102
if err != nil {
102103
return err
103104
}

programs/compute-budget/SetComputeUnitPrice.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package computebudget
1616

1717
import (
18+
"encoding/binary"
1819
"errors"
1920

2021
ag_binary "github.com/gagliardetto/solana-go/binary"
@@ -91,7 +92,7 @@ func (inst *SetComputeUnitPrice) EncodeToTree(parent ag_treeout.Branches) {
9192

9293
func (obj SetComputeUnitPrice) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) {
9394
// Serialize `MicroLamports` param:
94-
err = encoder.Encode(obj.MicroLamports)
95+
err = encoder.WriteUint64(obj.MicroLamports, binary.LittleEndian)
9596
if err != nil {
9697
return err
9798
}

programs/compute-budget/SetLoadedAccountsDataSizeLimit.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package computebudget
1616

1717
import (
18+
"encoding/binary"
1819
"errors"
1920

2021
ag_binary "github.com/gagliardetto/solana-go/binary"
@@ -91,7 +92,7 @@ func (inst *SetLoadedAccountsDataSizeLimit) EncodeToTree(parent ag_treeout.Branc
9192

9293
func (obj SetLoadedAccountsDataSizeLimit) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) {
9394
// Serialize `Bytes` param:
94-
err = encoder.Encode(obj.Bytes)
95+
err = encoder.WriteUint32(obj.Bytes, binary.LittleEndian)
9596
if err != nil {
9697
return err
9798
}

programs/stake/Lockup.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package stake
1616

1717
import (
18+
"encoding/binary"
1819
"errors"
1920

2021
bin "github.com/gagliardetto/solana-go/binary"
@@ -54,13 +55,13 @@ func (lockup *Lockup) UnmarshalWithDecoder(dec *bin.Decoder) error {
5455

5556
func (lockup *Lockup) MarshalWithEncoder(encoder *bin.Encoder) error {
5657
{
57-
err := encoder.Encode(*lockup.UnixTimestamp)
58+
err := encoder.WriteInt64(*lockup.UnixTimestamp, binary.LittleEndian)
5859
if err != nil {
5960
return err
6061
}
6162
}
6263
{
63-
err := encoder.Encode(*lockup.Epoch)
64+
err := encoder.WriteUint64(*lockup.Epoch, binary.LittleEndian)
6465
if err != nil {
6566
return err
6667
}

programs/stake/MoveLamports.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package stake
1616

1717
import (
18+
"encoding/binary"
1819
"errors"
1920
"fmt"
2021

@@ -93,7 +94,7 @@ func (inst *MoveLamports) UnmarshalWithDecoder(dec *bin.Decoder) error {
9394

9495
func (inst *MoveLamports) MarshalWithEncoder(encoder *bin.Encoder) error {
9596
{
96-
err := encoder.Encode(*inst.Lamports)
97+
err := encoder.WriteUint64(*inst.Lamports, binary.LittleEndian)
9798
if err != nil {
9899
return err
99100
}

programs/stake/MoveStake.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package stake
1616

1717
import (
18+
"encoding/binary"
1819
"errors"
1920
"fmt"
2021

@@ -93,7 +94,7 @@ func (inst *MoveStake) UnmarshalWithDecoder(dec *bin.Decoder) error {
9394

9495
func (inst *MoveStake) MarshalWithEncoder(encoder *bin.Encoder) error {
9596
{
96-
err := encoder.Encode(*inst.Lamports)
97+
err := encoder.WriteUint64(*inst.Lamports, binary.LittleEndian)
9798
if err != nil {
9899
return err
99100
}

programs/stake/Split.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package stake
1616

1717
import (
18+
"encoding/binary"
1819
"errors"
1920
"fmt"
2021

@@ -88,7 +89,7 @@ func (inst *Split) UnmarshalWithDecoder(dec *bin.Decoder) error {
8889

8990
func (inst *Split) MarshalWithEncoder(encoder *bin.Encoder) error {
9091
{
91-
err := encoder.Encode(*inst.Lamports)
92+
err := encoder.WriteUint64(*inst.Lamports, binary.LittleEndian)
9293
if err != nil {
9394
return err
9495
}

programs/stake/Withdraw.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package stake
1616

1717
import (
18+
"encoding/binary"
1819
"errors"
1920
"fmt"
2021

@@ -107,7 +108,7 @@ func (inst *Withdraw) UnmarshalWithDecoder(dec *bin.Decoder) error {
107108

108109
func (inst *Withdraw) MarshalWithEncoder(encoder *bin.Encoder) error {
109110
{
110-
err := encoder.Encode(*inst.Lamports)
111+
err := encoder.WriteUint64(*inst.Lamports, binary.LittleEndian)
111112
if err != nil {
112113
return err
113114
}

0 commit comments

Comments
 (0)