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) { |