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: Code Simplification and Optimization #12840

Merged
merged 3 commits into from
Dec 6, 2024

Conversation

sky-coderay
Copy link
Contributor

Description of changes:

  1. Simplification of obtaining code_hash: Instead of using the has_code variable and the then() method, the code_hash is directly computed through the if !account.code.is_empty() condition, which makes the code more straightforward.
  2. Simplification of the loop over the storage: Instead of using iter().filter().try_for_each(), I used a regular for loop, making the code easier to understand.
  3. Bytecode handling: The redundant variable has been removed, and code_hash is directly written to the database if it exists.

These changes make the code more readable and understandable, while functionality remains unchanged.

Description of changes:
1. Simplification of obtaining _code_hash_: Instead of using the _has_code_ variable and the _then()_ method, the _code_hash_ is directly computed through the _if !account.code.is_empty()_ condition, which makes the code more straightforward.
2. Simplification of the loop over the storage: Instead of using _iter().filter().try_for_each()_, I used a regular _for_ loop, making the code easier to understand.
3. Bytecode handling: The redundant variable has been removed, and _code_hash_ is directly written to the database if it exists.

These changes make the code more readable and understandable, while functionality remains unchanged.
@sky-coderay sky-coderay requested a review from gakonst as a code owner November 25, 2024 09:13
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

lgtm, only have 1 question about changed test

@sky-coderay
Copy link
Contributor Author

@mattsse Hi! Just a reminder about my PR . If everything looks good, it would be great if you could merge it. Thanks! 😊

Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

thanks, undid the unrelated test change that was blocking this pr

@mattsse mattsse added the C-debt A clean up/refactor of existing code label Dec 6, 2024
@mattsse mattsse merged commit 44a66d3 into paradigmxyz:main Dec 6, 2024
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-debt A clean up/refactor of existing code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants