Skip to content

Refactor logical operators#808

Merged
apoelstra merged 6 commits intorust-bitcoin:masterfrom
tcharding:logical-operators
Jan 26, 2022
Merged

Refactor logical operators#808
apoelstra merged 6 commits intorust-bitcoin:masterfrom
tcharding:logical-operators

Conversation

@tcharding
Copy link
Copy Markdown
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
Copy Markdown
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 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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