--Thanks!Vacalv
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
Dana,Do I understand correctly, that by porting you mean mainly to add the |postition| argument to insert stuff anywhere in the vector?
If yes, then I'm not sure -- the only callsite of inser_and_take I see in the CodeSearch, which supplies a different position than end() is in a unittest. And the insert & weak_erase pattern instances for ScopedVector I saw also always inserts at the end. Adding |position| would cluttering most of the code with "vector.end()," for no big benefit.
What do you think?
On Feb 13, 2015 2:18 AM, "Václav Brožek" <va...@chromium.org> wrote:
>
> Thanks, Dana.
>
> I respect the intention to make the ScopedVector API similar to std::vector.
>
> However, introducing the insert_and_take(position, src_start_iter, src_end_iter) has none of the benefits I hoped to get: the old callsites
>
> vector_a.insert(vector_a.end(), vector_b.begin(), vector_b.end());
> vector_b.weak_clear();
>
> would turn into very similar and slightly longer
>
> vector_a.insert_and_take(vector_a.end(), vector_b.begin(), vector_b.end());
> vector_b.weak_clear();
It would just be clear() now.
> Sure, the weak_clear() in the second case is optional, but leaving it out is a potential performance hit (iterating and deleting each (null) pointer instead of just flushing the vector).
What do you mean by flushing the vector?
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
On Feb 13, 2015 2:18 AM, "Václav Brožek" <va...@chromium.org> wrote:
>
> Thanks, Dana.
>
> I respect the intention to make the ScopedVector API similar to std::vector.
>
> However, introducing the insert_and_take(position, src_start_iter, src_end_iter) has none of the benefits I hoped to get: the old callsites
>
> vector_a.insert(vector_a.end(), vector_b.begin(), vector_b.end());
> vector_b.weak_clear();
>
> would turn into very similar and slightly longer
>
> vector_a.insert_and_take(vector_a.end(), vector_b.begin(), vector_b.end());
> vector_b.weak_clear();It would just be clear() now.
> Sure, the weak_clear() in the second case is optional, but leaving it out is a potential performance hit (iterating and deleting each (null) pointer instead of just flushing the vector).
What do you mean by flushing the vector?
weak_clear() seems like an inherently dangerous method that we wouldn't want to expose.
Given that std::vector<std::unique_ptr<T>> doesn't support anything analogous, I don't think it's worth it.
I thought we had linked_ptr so that we could use it in containers. I'd rather phase out ScopedVector today in favor of vector<linked_ptr<x>> and later migrate away from linked_ptr. But that's just me.