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

Unified Diff: src/utils/SkSHA1.cpp

Issue 14265010: Make SkSHA1 and SkM5 use common SkDigestHash result type (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: add_SkHashDigest_wrapper_for_cityhash 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/SkSHA1.cpp
===================================================================
--- src/utils/SkSHA1.cpp (revision 8685)
+++ src/utils/SkSHA1.cpp (working copy)
@@ -58,7 +58,7 @@
this->byteCount += inputLength;
}
-void SkSHA1::finish(Digest& digest) {
+void SkSHA1::finish(SkHashDigest& digest) {
// Get the number of bits before padding.
uint8_t bits[8];
encode(bits, this->byteCount << 3);
@@ -78,7 +78,17 @@
this->update(bits, 8);
// Write out digest.
- encode(digest.data, this->state);
+ // TODO(epoger): eliminate the extra 20-byte copy, by writing directly into digest.data???
+ // NO, we can't do that, because digest.data is immutable (wrapped in SkData).
+ // Or:
+ // 1. malloc 20 bytes here (wrapped in an SkData object),
+ // 2. write the digest into the SkData-wrapped 20 bytes,
+ // 3. bump the ref counter on that SkData-wrapped 20 bytes,
+ // 4. replace digest's fSkDataPtr with the new one
+ size_t digestSize = 20;
+ uint8_t tempDigestData[digestSize];
+ encode(tempDigestData, this->state);
+ digest.copyFrom(tempDigestData, digestSize);
#if defined(SK_SHA1_CLEAR_DATA)
// Clear state.

Powered by Google App Engine
This is Rietveld 408576698