Reland of Change base::Value::ListStorage to std::vector<base::Value>
The compilation on ChromeOS failed for the original CL
(http://crrev.com/2811673002), it is likely that a simple rebase fixes the
issue.
This patchset is equivalent to issue 2740143002 at patchset 14, simply another
rebase took place.
Original description follows:
This CL is a first step to inlining base::ListValue. It is proposed to use an
std::vector<base::Value> as the underlying ListStorage. This CL implements the
change and updates the code accordingly.
BUG=646113
TBR=brettw@chromium.org,rdevlin.cronin@chromium.org,flackr@chromium.org,skym@chromium.org,rsesek@chromium.org,bajones@chromium.org,dbeam@chromium.org,stevenjb@chromium.org
CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_trusty_blink_rel
Review-Url: https://codereview.chromium.org/2809023003
Cr-Commit-Position: refs/heads/master@{#463684}
CrOS-Libchrome-Original-Commit: a5676c607e107238b2d0cdd55e626c93669a92f1
diff --git a/base/values.h b/base/values.h
index ace8b43..075bc9f 100644
--- a/base/values.h
+++ b/base/values.h
@@ -49,7 +49,7 @@
class BASE_EXPORT Value {
public:
using DictStorage = base::flat_map<std::string, std::unique_ptr<Value>>;
- using ListStorage = std::vector<std::unique_ptr<Value>>;
+ using ListStorage = std::vector<Value>;
enum class Type {
NONE = 0,
@@ -390,9 +390,15 @@
// Returns the number of Values in this list.
size_t GetSize() const { return list_->size(); }
+ // Returns the capacity of storage for Values in this list.
+ size_t capacity() const { return list_->capacity(); }
+
// Returns whether the list is empty.
bool empty() const { return list_->empty(); }
+ // Reserves storage for at least |n| values.
+ void Reserve(size_t n);
+
// Sets the list item at the given index to be the Value specified by
// the value given. If the index beyond the current end of the list, null
// Values will be used to pad out the list.