diff options
author | Jack He <siyuanh@google.com> | 2020-06-17 02:15:23 -0700 |
---|---|---|
committer | Jack He <siyuanh@google.com> | 2020-06-17 16:15:27 -0700 |
commit | 44229e65df659fa78ab04dfafea65f756ac9b18f (patch) | |
tree | 3e63a2ea3a4c09de63c3f6974c3afa5bcb4bafbb /common/lru.h | |
parent | 91e3fd4004483ac27afb3d093223abce15da4133 (diff) | |
download | bt-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.h | 4 |
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; } |