Skip to content

Less cloning and additional pattern simplifications#3223

Merged
jaspervdm merged 10 commits into
mimblewimble:masterfrom
quentinlesceller:clean2
Feb 12, 2020
Merged

Less cloning and additional pattern simplifications#3223
jaspervdm merged 10 commits into
mimblewimble:masterfrom
quentinlesceller:clean2

Conversation

Comment thread api/src/router.rs
&Method::CONNECT => self.connect(req),
&Method::TRACE => self.trace(req),
&Method::HEAD => self.head(req),
match *req.method() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🥇

Comment thread chain/src/store.rs
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';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍

Comment thread core/src/libtx/proof.rs Outdated
for i in 0..17 {
msg[i + 3] = id_bytes[i];
}
msg[3..(17 + 3)].clone_from_slice(&id_bytes[..17]);
Copy link
Copy Markdown
Member

@antiochp antiochp Feb 6, 2020

Choose a reason for hiding this comment

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

I'm guessing tests will pick up any regressions here - hard to be 100% certain this is identical logic.

Copy link
Copy Markdown
Member Author

@quentinlesceller quentinlesceller Feb 6, 2020

Choose a reason for hiding this comment

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

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.

b.copy_from_slice(&bytes[0..64]);
secp::Signature::from_compact(&static_secp, &b)
.map(|val| Some(val))
.map(Some)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

😮 never seen this before. 👍

Copy link
Copy Markdown
Contributor

@jaspervdm jaspervdm left a comment

Choose a reason for hiding this comment

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

Nice improvements for legibility and general cleanliness :) I made a few comments

Comment thread api/src/handlers/blocks_api.rs
Comment thread api/src/rest.rs
Comment thread api/src/handlers/chain_api.rs
Comment thread core/src/core/transaction.rs Outdated
Comment thread core/src/libtx/proof.rs
Comment thread pool/src/transaction_pool.rs Outdated
Comment thread pool/src/transaction_pool.rs Outdated
@jaspervdm jaspervdm merged commit 04a0123 into mimblewimble:master Feb 12, 2020
@quentinlesceller quentinlesceller deleted the clean2 branch February 14, 2020 14:43
@antiochp antiochp mentioned this pull request Feb 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants