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

feat: reduce bytecode by removing unnecessary return values #265

Merged

Conversation

TomAFrench
Copy link
Contributor

@TomAFrench TomAFrench commented Mar 8, 2023

validateParameters never returns a non-empty reason as it will always revert if an error has occurred. It will also only return in the case where success == true. We then don't need to spend the bytecode associated with returning (true, "") as these return values aren't used.

This removes ~0.09kB of bytecode (giving us plenty of space for #260).

I also noticed that changePoolParameters seems to not be being inlined properly by the compiler. Considering how small the function is you could inline it manually (as you do in _createPool) however I've removed this inlining for consistency as it's a relatively small change in bytecode size.

Copy link
Contributor

@Alexangelj Alexangelj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good - We've been battling contract size so if we can get bytecode reductions elsewhere that would be great, we'd be able to use more runs on the compiler maybe so optimize per call

@clemlak clemlak merged commit d8a1d24 into primitivefinance:main Mar 9, 2023
@TomAFrench TomAFrench deleted the remove-unnecessary-returns branch March 9, 2023 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants