Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lang: Optimize sized fields when using LazyAccount #3218

Conversation

acheroncrypto
Copy link
Collaborator

Problem

We currently read the account data and get the offset to get each field's size:

let size = quote! {
<#ty as anchor_lang::__private::Lazy>::size_of(
&self.__info.data.borrow()[self.#offset_of_ident()..]
)
};

This is very inefficient and unnecessary if the type is sized.

Summary of changes

Add associated constant, SIZED, and use it to decide whether to read the account data and get the offset or not.

Copy link

vercel bot commented Sep 1, 2024

@acheroncrypto is attempting to deploy a commit to the coral-xyz Team on Vercel.

A member of the Team first needs to authorize it.

@acheroncrypto acheroncrypto added lang fix Bug fix PR labels Sep 1, 2024
@acheroncrypto acheroncrypto merged commit 06527e5 into coral-xyz:master Sep 2, 2024
50 of 51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fix PR lang
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant