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

Unified Diff: include/core/SkWriter32.h

Issue 145053003: Have peek32 return uint32_t& to make it harder to look at more than 4 bytes. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 11 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
« no previous file with comments | « no previous file | src/core/SkPictureRecord.cpp » ('j') | src/core/SkPictureRecord.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkWriter32.h
diff --git a/include/core/SkWriter32.h b/include/core/SkWriter32.h
index 6bb59c5dbc703f95f29f9645332747a519b32921..3d80a7f74ccbd9ca4fc28a8c926f886562495af0 100644
--- a/include/core/SkWriter32.h
+++ b/include/core/SkWriter32.h
@@ -79,18 +79,16 @@ public:
return p;
}
- // return the address of the 4byte int at the specified offset (which must
- // be a multiple of 4. This does not allocate any new space, so the returned
- // address is only valid for 1 int.
- uint32_t* peek32(size_t offset) {
+ // Return a reference to the 4 bytes at offset, which must be a multiple of 4.
+ uint32_t& peek32(size_t offset) {
SkASSERT(SkAlign4(offset) == offset);
const int count = SkToInt(offset/4);
SkASSERT(count < fCount);
if (count < this->externalCount()) {
- return fExternal + count;
+ return fExternal[count];
}
- return &fInternal[count - this->externalCount()];
+ return fInternal[count - this->externalCount()];
}
bool writeBool(bool value) {
@@ -215,8 +213,7 @@ public:
/**
* Move the cursor back to offset bytes from the beginning.
- * This has the same restrictions as peek32: offset must be <= size() and
- * offset must be a multiple of 4.
+ * offset must be a multiple of 4 no greater than size().
*/
void rewindToOffset(size_t offset) {
SkASSERT(SkAlign4(offset) == offset);
« no previous file with comments | « no previous file | src/core/SkPictureRecord.cpp » ('j') | src/core/SkPictureRecord.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698