Merge "Fix LruCache, allow std:string caching" am: 1477714262
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2627034
Change-Id: I633542894afa2dd1a8a6f84c222097bd41a4e68e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/libutils/LruCache_test.cpp b/libutils/LruCache_test.cpp
index 8b16947..5cd3cbb 100644
--- a/libutils/LruCache_test.cpp
+++ b/libutils/LruCache_test.cpp
@@ -29,6 +29,8 @@
struct ComplexKey {
int k;
+ explicit ComplexKey() : k(0) { instanceCount += 1; }
+
explicit ComplexKey(int k) : k(k) {
instanceCount += 1;
}
@@ -57,6 +59,8 @@
struct ComplexValue {
int v;
+ explicit ComplexValue() : v(0) { instanceCount += 1; }
+
explicit ComplexValue(int v) : v(v) {
instanceCount += 1;
}
@@ -83,10 +87,9 @@
struct KeyFailsOnCopy : public ComplexKey {
public:
- KeyFailsOnCopy(const KeyFailsOnCopy& key) : ComplexKey(key) {
- ADD_FAILURE();
- }
- KeyFailsOnCopy(int key) : ComplexKey(key) { }
+ KeyFailsOnCopy() : ComplexKey() {}
+ KeyFailsOnCopy(const KeyFailsOnCopy& key) : ComplexKey(key) { ADD_FAILURE(); }
+ KeyFailsOnCopy(int key) : ComplexKey(key) {}
};
} // namespace
diff --git a/libutils/include/utils/LruCache.h b/libutils/include/utils/LruCache.h
index b4243a3..70901b6 100644
--- a/libutils/include/utils/LruCache.h
+++ b/libutils/include/utils/LruCache.h
@@ -161,12 +161,12 @@
// Implementation is here, because it's fully templated
template <typename TKey, typename TValue>
LruCache<TKey, TValue>::LruCache(uint32_t maxCapacity)
- : mSet(new LruCacheSet())
- , mListener(nullptr)
- , mOldest(nullptr)
- , mYoungest(nullptr)
- , mMaxCapacity(maxCapacity)
- , mNullValue(0) {
+ : mSet(new LruCacheSet()),
+ mListener(nullptr),
+ mOldest(nullptr),
+ mYoungest(nullptr),
+ mMaxCapacity(maxCapacity),
+ mNullValue{} {
mSet->max_load_factor(1.0);
};