blink::WebVector should support the vector construction patterns we need |
|||||
Issue descriptionIn a couple of scenarios, I find myself building a WebVector by first constructing a std::vector with the desired data, and then using the WebVector constructor that std::moves a std::vector in. For example, WebVector's sized constructor cannot be used with types that do not have a default constructor, or for types that don't support moving and have an expensive copy operator. In that case, I've been doing the following dance. std::vector<WebType> vector; vector.reserve(final_size); for (size_t i = 0; i < final_size; ++i) vector.emplace_back(...); WebVector<WebType> web_vector(std::move(vector)); We should add any necessary supporting functions to WebVector so we can construct the vectors we need directly, without going through an std::vector. I will be submitting CLs for the cases I encounter. So far, this bug covers: * in-place construction via emplace_back, for types where default construction + assignment is expensive * types without a default constructor * resize() for use with std::unique
,
Jan 4 2018
,
Jan 6 2018
https://crrev.com/c/850576 also addresses this issue. I set the Bug: header on it incorrectly.
,
Jan 6 2018
,
Jan 6 2018
I repurposed this issue to track all the WebVector construction patterns that I'm using.
,
Jan 8 2018
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/5ffcbbf7625bdfc6cc239f531fc3a6437fbf776a commit 5ffcbbf7625bdfc6cc239f531fc3a6437fbf776a Author: Victor Costan <pwnall@chromium.org> Date: Mon Jan 08 21:37:16 2018 Blink: Add resize() to WebVector. This makes it possible to use std::sort and std::unique for duplicate removal directly on WebVector. Bug: 798868 Change-Id: Ib5981be5acb1a5224e217def55f93285419044dd Reviewed-on: https://chromium-review.googlesource.com/852554 Reviewed-by: Kentaro Hara <haraken@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Commit-Queue: Victor Costan <pwnall@chromium.org> Cr-Commit-Position: refs/heads/master@{#527763} [modify] https://crrev.com/5ffcbbf7625bdfc6cc239f531fc3a6437fbf776a/third_party/WebKit/Source/platform/WebVectorTest.cpp [modify] https://crrev.com/5ffcbbf7625bdfc6cc239f531fc3a6437fbf776a/third_party/WebKit/public/platform/WebVector.h
,
Jan 9 2018
|
|||||
►
Sign in to add a comment |
|||||
Comment 1 by bugdroid1@chromium.org
, Jan 4 2018