Skip to content
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

Closed
wants to merge 6 commits into from

Conversation

@Squareys
Copy link
Contributor

Squareys commented Dec 21, 2019

Hi @mosra !

As discussed via gitter, here is ArrayView input support for Sha1 << and the removal of DebugStl.h from AbstractHash.

Cheers,
Jonathan

src/Corrade/Utility/Sha1.h Show resolved Hide resolved
src/Corrade/Utility/Sha1.cpp Outdated Show resolved Hide resolved
Squareys added 2 commits Dec 21, 2019
Signed-off-by: Squareys <squareys@googlemail.com>
Signed-off-by: Squareys <squareys@googlemail.com>
@Squareys Squareys force-pushed the Squareys:hash-array-view branch from e151d0a to 3d0bd29 Dec 22, 2019
@codecov-io

This comment has been minimized.

Copy link

codecov-io commented Dec 22, 2019

Codecov Report

Merging #85 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
src/Corrade/Utility/Sha1.h 100% <ø> (ø) ⬆️
src/Corrade/Utility/Sha1.cpp 100% <100%> (ø) ⬆️
src/Corrade/Utility/AbstractHash.h 96.55% <100%> (ø) ⬆️
src/Corrade/Utility/FileWatcher.cpp 97.87% <0%> (-2.13%) ⬇️
src/Corrade/TestSuite/Tester.h 100% <0%> (ø) ⬆️
src/Corrade/Interconnect/Emitter.cpp 100% <0%> (ø) ⬆️
src/Corrade/Utility/Format.h 100% <0%> (ø) ⬆️
.../Corrade/TestSuite/Implementation/BenchmarkStats.h 100% <0%> (ø) ⬆️
src/Corrade/Utility/Implementation/tweakable.h 100% <0%> (ø) ⬆️
src/Corrade/TestSuite/Comparator.cpp 100% <0%> (ø) ⬆️
... and 21 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0280fbe...bf7c1e3. Read the comment docs.

@Squareys

This comment has been minimized.

Copy link
Contributor Author

Squareys commented Dec 22, 2019

@mosra I addressed the feedback and moved the code to use _buffer[128] instead of std::string.

Copy link
Owner

mosra left a comment

There's one critical issue and a few minor things, but apart from that looks good I guess :)

src/Corrade/Utility/Sha1.h Outdated Show resolved Hide resolved
src/Corrade/Utility/Test/Sha1Test.cpp Outdated Show resolved Hide resolved
src/Corrade/Utility/Sha1.h Outdated Show resolved Hide resolved
src/Corrade/Utility/Sha1.cpp Outdated Show resolved Hide resolved
src/Corrade/Utility/Test/Sha1Test.py Show resolved Hide resolved
src/Corrade/Utility/Sha1.h Outdated Show resolved Hide resolved
Squareys added 2 commits Dec 21, 2019
Signed-off-by: Squareys <squareys@googlemail.com>
Signed-off-by: Squareys <squareys@googlemail.com>
@Squareys Squareys force-pushed the Squareys:hash-array-view branch from 3d0bd29 to 3309f54 Dec 22, 2019
@Squareys

This comment has been minimized.

Copy link
Contributor Author

Squareys commented Dec 22, 2019

@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.

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.

This comment has been minimized.

Copy link
@mosra

mosra Dec 22, 2019

Owner

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.

This comment has been minimized.

Copy link
@Squareys

Squareys Dec 22, 2019

Author Contributor

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? 🤔

This comment has been minimized.

Copy link
@Squareys

Squareys Dec 23, 2019

Author Contributor

I removed this line.

This comment has been minimized.

Copy link
@mosra

mosra Dec 30, 2019

Owner

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.

doc/snippets/Utility.cpp Show resolved Hide resolved
@Squareys Squareys force-pushed the Squareys:hash-array-view branch from 3309f54 to 7eedb23 Dec 23, 2019
Squareys and others added 2 commits Dec 22, 2019
Signed-off-by: Squareys <squareys@googlemail.com>
Co-authored-by: mosra <mosra@centrum.cz>
…icit

Signed-off-by: Squareys <squareys@googlemail.com>
@Squareys Squareys force-pushed the Squareys:hash-array-view branch from 7eedb23 to bf7c1e3 Dec 23, 2019
@Squareys

This comment has been minimized.

Copy link
Contributor Author

Squareys commented Dec 23, 2019

@mosra I made those two changes (see answers to those comments).

@mosra mosra added this to the 2020.0a milestone Dec 30, 2019
@mosra mosra added this to TODO in Utility via automation Dec 30, 2019
@mosra

This comment has been minimized.

Copy link
Owner

mosra commented Dec 30, 2019

Merged with a bunch of minor doc clarifications / commit squashing in 004f974...f627677. Thank you!

@mosra mosra closed this Dec 30, 2019
Utility automation moved this from TODO to Done Dec 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Utility
  
Done
3 participants
You can’t perform that action at this time.