aboutsummaryrefslogtreecommitdiff
path: root/common/lru.h
diff options
context:
space:
mode:
authorJack He <siyuanh@google.com>2020-06-17 02:15:23 -0700
committerJack He <siyuanh@google.com>2020-06-17 16:15:27 -0700
commit44229e65df659fa78ab04dfafea65f756ac9b18f (patch)
tree3e63a2ea3a4c09de63c3f6974c3afa5bcb4bafbb /common/lru.h
parent91e3fd4004483ac27afb3d093223abce15da4133 (diff)
downloadbt-44229e65df659fa78ab04dfafea65f756ac9b18f.tar.gz
LruCache: Allow Get to take nullptr
* When nullptr is given, copy of item is omitted Bug: 143515989 Test: atest --host bluetooth_test_common Change-Id: If5405611e8a32709bf0bf18f416d17adbd07b5ea
Diffstat (limited to 'common/lru.h')
-rw-r--r--common/lru.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/common/lru.h b/common/lru.h
index 68c227924..791e74e16 100644
--- a/common/lru.h
+++ b/common/lru.h
@@ -83,7 +83,9 @@ class LruCache {
node_list_.erase(list_iterator);
node_list_.push_front(node);
map_iterator->second = node_list_.begin();
- *value = node.second;
+ if (value != nullptr) {
+ *value = node.second;
+ }
return true;
}