Commit 4e26e259 authored by Devlin Cronin's avatar Devlin Cronin Committed by Commit Bot

[Extensions Cleanup] Update BaseSetOperators<T>::Map type to unique_ptr

Update the underlying BaseSetOperators<T>::Map type to use
std::unique_ptrs instead of linked_ptrs.

Bug: 907661
Change-Id: I2161ca2acc513ee5d78cc32b14f27199f5a7d1b7
Reviewed-on: https://chromium-review.googlesource.com/c/1351422
Commit-Queue: Devlin <rdevlin.cronin@chromium.org>
Reviewed-by: default avatarIstiaque Ahmed <lazyboy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612317}
parent 4b985559
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include <map> #include <map>
#include <memory> #include <memory>
#include "base/memory/linked_ptr.h" #include "base/logging.h"
namespace extensions { namespace extensions {
...@@ -31,8 +31,7 @@ class BaseSetOperators { ...@@ -31,8 +31,7 @@ class BaseSetOperators {
typedef typename BaseSetOperatorsTraits<T>::ElementType ElementType; typedef typename BaseSetOperatorsTraits<T>::ElementType ElementType;
typedef typename BaseSetOperatorsTraits<T>::ElementIDType ElementIDType; typedef typename BaseSetOperatorsTraits<T>::ElementIDType ElementIDType;
// TODO(devlin): Un-link-ptr-ify this. using Map = std::map<ElementIDType, std::unique_ptr<ElementType>>;
using Map = std::map<ElementIDType, linked_ptr<ElementType>>;
class const_iterator : class const_iterator :
public std::iterator<std::input_iterator_tag, const ElementType*> { public std::iterator<std::input_iterator_tag, const ElementType*> {
...@@ -249,7 +248,7 @@ class BaseSetOperators { ...@@ -249,7 +248,7 @@ class BaseSetOperators {
void insert(std::unique_ptr<ElementType> item) { void insert(std::unique_ptr<ElementType> item) {
ElementIDType id = item->id(); ElementIDType id = item->id();
map_[id].reset(item.release()); map_[id] = std::move(item);
} }
size_t size() const { return map_.size(); } size_t size() const { return map_.size(); }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment