Less cloning and additional pattern simplifications#3223
Merged
Conversation
antiochp
reviewed
Feb 6, 2020
| &Method::CONNECT => self.connect(req), | ||
| &Method::TRACE => self.trace(req), | ||
| &Method::HEAD => self.head(req), | ||
| match *req.method() { |
antiochp
reviewed
Feb 6, 2020
| const COMMIT_POS_HGT_PREFIX: u8 = 'p' as u8; | ||
| const BLOCK_INPUT_BITMAP_PREFIX: u8 = 'B' as u8; | ||
| const BLOCK_SUMS_PREFIX: u8 = 'M' as u8; | ||
| const BLOCK_HEADER_PREFIX: u8 = b'h'; |
antiochp
reviewed
Feb 6, 2020
| for i in 0..17 { | ||
| msg[i + 3] = id_bytes[i]; | ||
| } | ||
| msg[3..(17 + 3)].clone_from_slice(&id_bytes[..17]); |
Member
There was a problem hiding this comment.
I'm guessing tests will pick up any regressions here - hard to be 100% certain this is identical logic.
Member
Author
There was a problem hiding this comment.
The loop is simply copying the bytes from id_bytes from 0 to 17 to the msg structure. I actually removed the addition which I think is a bit confusing. But overall should be faster thanks to memcpy.
antiochp
reviewed
Feb 6, 2020
| b.copy_from_slice(&bytes[0..64]); | ||
| secp::Signature::from_compact(&static_secp, &b) | ||
| .map(|val| Some(val)) | ||
| .map(Some) |
jaspervdm
reviewed
Feb 12, 2020
Contributor
jaspervdm
left a comment
There was a problem hiding this comment.
Nice improvements for legibility and general cleanliness :) I made a few comments
jaspervdm
approved these changes
Feb 12, 2020
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Simplify, optimize some part of code, remove cloning and other pattern simplifications.
Rules: