Skip to content

Commit

Permalink
inline try_new for internal meta (#2593)
Browse files Browse the repository at this point in the history
  • Loading branch information
apfitzge authored Aug 15, 2024
1 parent a5bde5f commit 94bfbd5
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions transaction-view/src/address_table_lookup_meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ impl AddressTableLookupMeta {
/// ATL.
/// This function will parse each ATL to ensure the data is well-formed,
/// but will not cache data related to these ATLs.
#[inline(always)]
pub fn try_new(bytes: &[u8], offset: &mut usize) -> Result<Self> {
// Maximum number of ATLs should be represented by a single byte,
// thus the MSB should not be set.
Expand Down
1 change: 1 addition & 0 deletions transaction-view/src/instructions_meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ impl InstructionsMeta {
/// This function will parse each individual instruction to ensure the
/// instruction data is well-formed, but will not cache data related to
/// these instructions.
#[inline(always)]
pub fn try_new(bytes: &[u8], offset: &mut usize) -> Result<Self> {
// Read the number of instructions at the current offset.
// Each instruction needs at least 3 bytes, so do a sanity check here to
Expand Down
1 change: 1 addition & 0 deletions transaction-view/src/message_header_meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub(crate) struct MessageHeaderMeta {
}

impl MessageHeaderMeta {
#[inline(always)]
pub fn try_new(bytes: &[u8], offset: &mut usize) -> Result<Self> {
// Get the message offset.
// We know the offset does not exceed packet length, and our packet
Expand Down
1 change: 1 addition & 0 deletions transaction-view/src/signature_meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub(crate) struct SignatureMeta {
impl SignatureMeta {
/// Get the number of signatures and the offset to the first signature in
/// the transaction packet, starting at the given `offset`.
#[inline(always)]
pub(crate) fn try_new(bytes: &[u8], offset: &mut usize) -> Result<Self> {
// Maximum number of signatures should be represented by a single byte,
// thus the MSB should not be set.
Expand Down
1 change: 1 addition & 0 deletions transaction-view/src/static_account_keys_meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub struct StaticAccountKeysMeta {
}

impl StaticAccountKeysMeta {
#[inline(always)]
pub fn try_new(bytes: &[u8], offset: &mut usize) -> Result<Self> {
// Max size must not have the MSB set so that it is size 1.
const _: () = assert!(MAX_STATIC_ACCOUNTS_PER_PACKET & 0b1000_0000 == 0);
Expand Down

0 comments on commit 94bfbd5

Please sign in to comment.