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
Utility: Minor improvements to Sha1 and AbstractHash #85
Conversation
Signed-off-by: Squareys <squareys@googlemail.com>
Signed-off-by: Squareys <squareys@googlemail.com>
e151d0a
to
3d0bd29
Compare
Codecov Report
@@ Coverage Diff @@
## master #85 +/- ##
==========================================
+ Coverage 97.65% 97.68% +0.02%
==========================================
Files 89 89
Lines 6063 6180 +117
==========================================
+ Hits 5921 6037 +116
- Misses 142 143 +1
Continue to review full report at Codecov.
|
@mosra I addressed the feedback and moved the code to use |
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.
There's one critical issue and a few minor things, but apart from that looks good I guess :)
Signed-off-by: Squareys <squareys@googlemail.com>
Signed-off-by: Squareys <squareys@googlemail.com>
3d0bd29
to
3309f54
Compare
@mosra Done. Thanks for all the feedback! I also added a code snippet for the usage, I find those particularly useful when searching through the docs. |
src/Corrade/Utility/Sha1.h
Outdated
class CORRADE_UTILITY_EXPORT Sha1: public AbstractHash<20> { | ||
public: | ||
/** | ||
* @brief Digest of given data | ||
* | ||
* Convenience function for @cpp (Utility::Sha1{} << data).digest() @ce. | ||
* The @cpp '\0' @ce delimiter is not included. |
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 wouldn't mention this here at all, it's misleading -- what it does do when your string has a 0 byte in the middle? Or when data.back() == '\0'
? The std::string historically didn't have to allocate extra space for the 0-delimiter (it does so only from c++11).
Same below and in the snippet above, it only adds confusion IMHO -- it takes all size()
bytes from it, which is what one expects, so it doesn't need to be mentioned explicitly.
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.
It cause a lot of confusion for me not knowing whether or not it does include the final delimiter and I originally expected it to, so having this somewhere would make sense to me... maybe as a note? If there is \0
in the middle, it will already mess up there with the char* => string conversion and use strlen... maybe add a note for that?
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 removed this line.
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.
If there is \0 in the middle, it will already mess up there with the char* => string conversion and use strlen
Nope, you can do std::string{"ab\0cde"}
and that'll make the string six characters long with a zero in the middle.
3309f54
to
7eedb23
Compare
Signed-off-by: Squareys <squareys@googlemail.com> Co-authored-by: mosra <mosra@centrum.cz>
…icit Signed-off-by: Squareys <squareys@googlemail.com>
7eedb23
to
bf7c1e3
Compare
@mosra I made those two changes (see answers to those comments). |
Merged with a bunch of minor doc clarifications / commit squashing in 004f974...f627677. Thank you! |
Hi @mosra !
As discussed via gitter, here is ArrayView input support for
Sha1 <<
and the removal ofDebugStl.h
from AbstractHash.Cheers,
Jonathan