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

Unified Diff: include/private/SkTHash.h

Issue 1280653003: Add approxBytesUsed to hashes. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 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 | tests/HashTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/private/SkTHash.h
diff --git a/include/private/SkTHash.h b/include/private/SkTHash.h
index ffcdea5329f8e0286539a24839740ac707e6ddd8..561fc89b59e35dd23a1a61f18752da18a8c1a5f7 100644
--- a/include/private/SkTHash.h
+++ b/include/private/SkTHash.h
@@ -35,6 +35,9 @@ public:
// How many entries are in the table?
int count() const { return fCount; }
+ // Approximately how many bytes of memory do we use beyond sizeof(*this)?
+ size_t approxBytesUsed() const { return fCapacity * sizeof(Slot); }
+
// !!!!!!!!!!!!!!!!! CAUTION !!!!!!!!!!!!!!!!!
// set(), find() and foreach() all allow mutable access to table entries.
// If you change an entry so that it no longer has the same key, all hell
@@ -199,6 +202,9 @@ public:
// How many key/value pairs are in the table?
int count() const { return fTable.count(); }
+ // Approximately how many bytes of memory do we use beyond sizeof(*this)?
+ size_t approxBytesUsed() const { return fTable.approxBytesUsed(); }
+
// N.B. The pointers returned by set() and find() are valid only until the next call to set().
// Set key to val in the table, replacing any previous value with the same key.
@@ -259,6 +265,9 @@ public:
// How many items are in the set?
int count() const { return fTable.count(); }
+ // Approximately how many bytes of memory do we use beyond sizeof(*this)?
+ size_t approxBytesUsed() const { return fTable.approxBytesUsed(); }
+
// Copy an item into the set.
void add(const T& item) { fTable.set(item); }
« no previous file with comments | « no previous file | tests/HashTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698