8000 Refactor logical operators by tcharding · Pull Request #808 · rust-bitcoin/rust-bitcoin · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Refactor logical operators #808

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

Merged
merged 6 commits into from
Jan 26, 2022

Conversation

tcharding
Copy link
Member

In an effort to make the code clearer and more explicit, do various refactorings around logical operators. Each done as a separate patch to ease review and limit scope of discussion.

Based on review of #806

In preparation for refactoring `read_scriptbool` add passing unit
tests.
Refactor and simplify the logical operators in `read_scriptbool`.

Refactor only, no logic changes.
Refactor with the aim of simplifying `is_p2kh`. This function is covered
sufficiently by current unit tests.

Refactor only, no logic changes.
In an effort to make code containing multi-line logical AND clearer to
read put the operator at the start of the line.
Refactor with the aim of making the code easier to read. Code path is
covered by current unit tests.

Refactor only, no logic changes.
apoelstra
apoelstra previously approved these changes Jan 25, 2022
Copy link
Member
@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

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

8000

ACK 4b6e866

I do find these easier to follow than their versions in the other PR :)

Kixunil
Kixunil previously approved these changes Jan 25, 2022
Copy link
Collaborator
@Kixunil Kixunil left a comment

Choose a reason for hiding this comment

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

ACK 4b6e866

Simplify `read_scriptbool` by doing:

- Use `split_last` to get at the last element
- Mask the last byte against ^0x80 instead of using two equality
  statements
@tcharding tcharding dismissed stale reviews from Kixunil and apoelstra via df7bb03 January 26, 2022 05:55
Copy link
Collaborator
@Kixunil Kixunil left a comment

Choose a reason for hiding this comment

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

Beautiful!

ACK df7bb03

Copy link
Member
@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

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

ACK df7bb03

@apoelstra apoelstra merged commit cb35766 into rust-bitcoin:master Jan 26, 2022
@tcharding tcharding deleted the logical-operators branch January 26, 2022 21:13
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
0