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

chore(all): rewrite runtime type assertions to not allocate memory #730

Open
qdm12 opened this issue Jan 3, 2025 · 1 comment
Open

chore(all): rewrite runtime type assertions to not allocate memory #730

qdm12 opened this issue Jan 3, 2025 · 1 comment
Labels

Comments

@qdm12
Copy link
Collaborator

qdm12 commented Jan 3, 2025

var _ MyInterface = &MyStruct{}

does allocate memory at global scope. Over many packages, that can build up to a few kilo bytes used for no reason.

We can batch replace these with:

var _ MyInterface = (*MyStruct)(nil)

⚠️ Don't modify upstream geth code!

We can use the regex _ [A-Za-z].*[ ]+=[ ]+&[A-Za-z].*\{\} to find all of them and replace them manually one by one. There are only around 40 of them as of today.

@qdm12 qdm12 added the cleanup label Jan 3, 2025
@qdm12 qdm12 mentioned this issue Jan 3, 2025
@darioush
Copy link
Collaborator

darioush commented Jan 3, 2025

Great idea, however we should be careful to not apply this to shared files with upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants