Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(246)

Unified Diff: src/utils/SkMD5.cpp

Issue 14265010: Make SkSHA1 and SkM5 use common SkDigestHash result type (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/utils/SkMD5.cpp
===================================================================
--- src/utils/SkMD5.cpp (revision 8685)
+++ src/utils/SkMD5.cpp (working copy)
@@ -60,7 +60,7 @@
this->byteCount += inputLength;
}
-void SkMD5::finish(Digest& digest) {
+void SkMD5::finish(SkHashDigest& digest) {
// Get the number of bits before padding.
uint8_t bits[8];
encode(bits, this->byteCount << 3);
@@ -80,7 +80,17 @@
this->update(bits, 8);
// Write out digest.
- encode(digest.data, this->state);
+ // TODO(epoger): eliminate the extra 16-byte copy, by writing directly into digest.data???
epoger 2013/04/15 18:21:38 Any thoughts on this? I intend to get to work on
+ // NO, we can't do that, because digest.data is immutable (wrapped in SkData).
+ // Or:
+ // 1. malloc 16 bytes here (wrapped in an SkData object),
+ // 2. write the digest into the SkData-wrapped 16 bytes,
+ // 3. bump the ref counter on that SkData-wrapped 16 bytes,
+ // 4. replace digest's fSkDataPtr with the new one
+ size_t digestSize = 16;
+ uint8_t tempDigestData[digestSize];
+ encode(tempDigestData, this->state);
+ digest.set(tempDigestData, digestSize);
#if defined(SK_MD5_CLEAR_DATA)
// Clear state.
@@ -90,12 +100,12 @@
struct F { uint32_t operator()(uint32_t x, uint32_t y, uint32_t z) {
//return (x & y) | ((~x) & z);
- return ((y ^ z) & x) ^ z; //equivelent but faster
+ return ((y ^ z) & x) ^ z; //equivalent but faster
}};
struct G { uint32_t operator()(uint32_t x, uint32_t y, uint32_t z) {
return (x & z) | (y & (~z));
- //return ((x ^ y) & z) ^ y; //equivelent but slower
+ //return ((x ^ y) & z) ^ y; //equivalent but slower
}};
struct H { uint32_t operator()(uint32_t x, uint32_t y, uint32_t z) {
« src/utils/SkMD5.h ('K') | « src/utils/SkMD5.h ('k') | src/utils/SkSHA1.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698