-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
cksum: small improvements, l10n #9532
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
base: main
Are you sure you want to change the base?
Conversation
|
GNU testsuite comparison: |
5461873 to
c6b9693
Compare
c6b9693 to
be080a2
Compare
CodSpeed Performance ReportMerging #9532 will degrade performances by 16.41%Comparing Summary
Benchmarks breakdown
Footnotes
|
|
GNU testsuite comparison: |
4e9151b to
086d610
Compare
|
GNU testsuite comparison: |
c96ed79 to
dc8063d
Compare
|
GNU testsuite comparison: |
|
It looks like the localized messages I added add a significant overhead to many other tools :/ Not sure how to improve this. |
| sum.parse::<u16>().unwrap(), | ||
| match (options.algo_kind, sum) { | ||
| (SizedAlgoKind::Sysv, DigestOutput::U16(sum)) => print!( | ||
| "{prefix}{sum} {}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the printing of prefix here, and in the other arms of this match, correct? I'm asking because it is already printed on line 155.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed it's wrong, I forgot to remove the print above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 👍
dc8063d to
7ba5109
Compare
|
GNU testsuite comparison: |
| use hex::encode; | ||
| use std::io::{self, Write}; | ||
|
|
||
| use data_encoding::BASE64; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You forgot to add data_encoding to the sum feature in src/uucore/Cargo.toml. Currently there is an "unresolved import data_encoding" error when I try to run cargo test --features=sum --no-default-features
| impl_digest_shake!(Shake128, 256); | ||
| impl_digest_shake!(Shake256, 512); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are the values 256 and 512 correct? With the impl_digest_common macro, the values correspond to the bits in the algorithm name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I saw, Shake algorithms are not available in GNU, so I have no point of comparison. I just used the values that kept the test passing while still removing the code that previously handled the specific case of Shake.
| // Implements the Digest trait for sha2 / sha3 algorithms with variable output | ||
| macro_rules! impl_digest_shake { | ||
| ($algo_type: ty) => { | ||
| ($algo_type: ty, $output_bits: literal) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reason that the definition here is different than the one used for impl_digest_common (literal vs expr)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
literal is more restrictive than expr, and it's enough since I'm writing the number directly. I can switch to expr in case we want to change this later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use literal in both cases. In the other macro the number is also written directly.
| .all(|&b| b.is_ascii_alphanumeric() || b == b'+' || b == b'/') | ||
| { | ||
| return None; | ||
| while index < checksum.len() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use a for loop so you don't have to increase index yourself.
| while index < checksum.len() { | |
| for index in 0..checksum.len() { |
| // ASCII alphanumeric | ||
| [b'A'..=b'Z' | b'a'..=b'z' | b'0'..=b'9', ..] => { | ||
| index += 1; | ||
| continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The continue is not necessary.
| continue; |
| [b'+' | b'/', ..] => { | ||
| is_base64 = true; | ||
| index += 1; | ||
| continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
| continue; |
| // division by 2 converts the length of the Blake2b checksum from | ||
| // hexadecimal characters to bytes, as each byte is represented by | ||
| // two hexadecimal characters. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment no longer matches the code.
| // division by 2 converts the length of the Blake2b checksum from | |
| // hexadecimal characters to bytes, as each byte is represented by | |
| // two hexadecimal characters. |
| (AlgoKind::Blake2b, Some(expected_checksum.len())) | ||
| } | ||
| algo @ (AlgoKind::Sha2 | AlgoKind::Sha3) => { | ||
| // multiplication by 4 to get the number of bits |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // multiplication by 4 to get the number of bits | |
| // multiplication by 8 to get the number of bits |
cakebaker
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done :)
... to prevent a preemptive computation of the hex encoding.
to avoid decoding base64 and directly re-encoding it in hexadecimal
…-input filename print
7ba5109 to
935f0a9
Compare
|
GNU testsuite comparison: |
This MR brings a few changes to simplify and optimize some parts of the checksum computation
It depends on the #9511 MR