Skip to content

Commit f7ccd71

Browse files
committed
Pass Message as pointer
This seems to show up as runtime.duffcopy in my profiles.
1 parent d9db435 commit f7ccd71

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

message.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ func (mx *Message) UnmarshalBase64(b64 string) error {
415415
// in the actual address tables, and returns the accounts.
416416
// NOTE: you need to call `SetAddressTables` before calling this method,
417417
// so that the lookups can be associated with the accounts in the address tables.
418-
func (mx Message) GetAddressTableLookupAccounts() (PublicKeySlice, error) {
418+
func (mx *Message) GetAddressTableLookupAccounts() (PublicKeySlice, error) {
419419
err := mx.checkPreconditions()
420420
if err != nil {
421421
return nil, err
@@ -468,7 +468,7 @@ func (mx Message) IsResolved() bool {
468468
}
469469

470470
// GetAllKeys returns ALL the message's account keys (including the keys from resolved address lookup tables).
471-
func (mx Message) GetAllKeys() (keys PublicKeySlice, err error) {
471+
func (mx *Message) GetAllKeys() (keys PublicKeySlice, err error) {
472472
if mx.resolved {
473473
// If the message has been resolved, then the account keys have already
474474
// been appended to the `AccountKeys` field of the message.
@@ -642,7 +642,7 @@ func (mx *Message) UnmarshalLegacy(decoder *bin.Decoder) (err error) {
642642
return nil
643643
}
644644

645-
func (m Message) checkPreconditions() error {
645+
func (m *Message) checkPreconditions() error {
646646
// if this is versioned,
647647
// and there are > 0 lookups,
648648
// but the address table is empty,
@@ -654,7 +654,7 @@ func (m Message) checkPreconditions() error {
654654
return nil
655655
}
656656

657-
func (m Message) AccountMetaList() (AccountMetaSlice, error) {
657+
func (m *Message) AccountMetaList() (AccountMetaSlice, error) {
658658
err := m.checkPreconditions()
659659
if err != nil {
660660
return nil, err
@@ -678,7 +678,7 @@ func (m Message) AccountMetaList() (AccountMetaSlice, error) {
678678
return out, nil
679679
}
680680

681-
func (m Message) IsVersioned() bool {
681+
func (m *Message) IsVersioned() bool {
682682
return m.version != MessageVersionLegacy
683683
}
684684

@@ -786,7 +786,7 @@ func (m Message) HasAccount(account PublicKey) (bool, error) {
786786
return false, nil
787787
}
788788

789-
func (m Message) IsSigner(account PublicKey) bool {
789+
func (m *Message) IsSigner(account PublicKey) bool {
790790
// signers always in AccountKeys
791791
for idx, acc := range m.AccountKeys {
792792
if acc.Equals(account) {
@@ -802,14 +802,14 @@ func (m *Message) accountIndexIsSigner(index int) bool {
802802

803803
// numStaticAccounts returns the number of accounts that are always present in the
804804
// account keys list (i.e. all the accounts that are NOT in the lookup table).
805-
func (m Message) numStaticAccounts() int {
805+
func (m *Message) numStaticAccounts() int {
806806
if !m.resolved {
807807
return len(m.AccountKeys)
808808
}
809809
return len(m.AccountKeys) - m.NumLookups()
810810
}
811811

812-
func (m Message) isWritableInLookups(idx int) bool {
812+
func (m *Message) isWritableInLookups(idx int) bool {
813813
if idx < m.numStaticAccounts() {
814814
return false
815815
}
@@ -841,7 +841,7 @@ func (m Message) IsWritable(account PublicKey) (bool, error) {
841841
}
842842

843843
// uncheckedAccountIndexIsWritable does not check preconditions. It assumes index is an account index into the slice of resolved accounts.
844-
func (m Message) uncheckedAccountIndexIsWritable(index int) bool {
844+
func (m *Message) uncheckedAccountIndexIsWritable(index int) bool {
845845
h := m.Header
846846

847847
if index >= m.numStaticAccounts() {

0 commit comments

Comments
 (0)