Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Issue 1202153002: Add ListContainer::AppendByMoving (Closed)

Created:
5 years, 6 months ago by pdr.
Modified:
5 years, 5 months ago
Reviewers:
danakj
CC:
cc-bugs_chromium.org, chromium-reviews
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Add ListContainer::AppendByMoving This patch implements "void ListContainer::AppendByMoving(T item)" for appending items to a ListContainer without copying. Because the source item will not be destructed when moving to the destination, a new item is constructed in-place to prevent double-destruction and dev sadness. To support appending derived types when only the base type is known we memcpy the largest possible element size. BUG=484943 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Committed: https://crrev.com/737f36b52ce9137b242b8259b8f440c61e6b60ba Cr-Commit-Position: refs/heads/master@{#335826}

Patch Set 1 #

Patch Set 2 : Click here for one weird trick to make compilers love your patch #

Patch Set 3 : Appease the compiler overlords with the gift of a type literal suffix #

Total comments: 30

Patch Set 4 : Address reviewer comments #

Total comments: 2

Patch Set 5 : Address reviewer comments #

Unified diffs Side-by-side diffs Delta from patch set Stats (+157 lines, -2 lines) Patch
M cc/base/list_container.h View 1 2 3 4 4 chunks +17 lines, -0 lines 0 comments Download
M cc/base/list_container.cc View 1 chunk +4 lines, -0 lines 0 comments Download
M cc/base/list_container_unittest.cc View 1 2 3 4 4 chunks +136 lines, -2 lines 0 comments Download

Messages

Total messages: 14 (3 generated)
pdr.
5 years, 6 months ago (2015-06-23 06:23:12 UTC) #2
danakj
LGTM with a bunch of comments about style/comments https://codereview.chromium.org/1202153002/diff/40001/cc/base/list_container.h File cc/base/list_container.h (right): https://codereview.chromium.org/1202153002/diff/40001/cc/base/list_container.h#newcode288 cc/base/list_container.h:288: // ...
5 years, 6 months ago (2015-06-23 20:01:13 UTC) #3
danakj
https://codereview.chromium.org/1202153002/diff/40001/cc/base/list_container_unittest.cc File cc/base/list_container_unittest.cc (right): https://codereview.chromium.org/1202153002/diff/40001/cc/base/list_container_unittest.cc#newcode905 cc/base/list_container_unittest.cc:905: const unsigned long kMagicNumberToUseForLongSimpleDerivedElement = -1618ul; e:\b\build\slave\win\build\src\cc\base\list_container_unittest.cc(905) : warning ...
5 years, 6 months ago (2015-06-23 20:01:44 UTC) #4
pdr.
Thanks for the detailed review. PTAL https://codereview.chromium.org/1202153002/diff/40001/cc/base/list_container.h File cc/base/list_container.h (right): https://codereview.chromium.org/1202153002/diff/40001/cc/base/list_container.h#newcode288 cc/base/list_container.h:288: // Appends a ...
5 years, 6 months ago (2015-06-23 21:42:43 UTC) #5
danakj
https://codereview.chromium.org/1202153002/diff/60001/cc/base/list_container.h File cc/base/list_container.h (right): https://codereview.chromium.org/1202153002/diff/60001/cc/base/list_container.h#newcode300 cc/base/list_container.h:300: // Construct a new element in-pace so it can ...
5 years, 6 months ago (2015-06-23 22:20:08 UTC) #6
pdr.
TY, off to CQ
5 years, 6 months ago (2015-06-23 22:31:08 UTC) #8
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1202153002/80001
5 years, 6 months ago (2015-06-23 22:34:19 UTC) #10
commit-bot: I haz the power
Committed patchset #5 (id:80001)
5 years, 6 months ago (2015-06-24 00:23:47 UTC) #11
commit-bot: I haz the power
Patchset 5 (id:??) landed as https://crrev.com/737f36b52ce9137b242b8259b8f440c61e6b60ba Cr-Commit-Position: refs/heads/master@{#335826}
5 years, 6 months ago (2015-06-24 00:25:50 UTC) #12
jbroman
(retroactive, sorry) This is a very very big precondition to add (that the object can ...
5 years, 5 months ago (2015-06-29 14:04:37 UTC) #13
danakj
5 years, 5 months ago (2015-06-29 18:01:35 UTC) #14
Message was sent while issue was closed.
Hm, weak pointers.

It looks like canMoveWithMemcpy ultimately uses __has_trivial_assign, which
would return false if the if the class has any virtual functions.
http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/...

Maybe the right way to resolve this is to use moveable display items and
std::move once we can do that. Should we file a bug and put a warning/TODO
about it?

On Mon, Jun 29, 2015 at 7:04 AM, <jbroman@chromium.org> wrote:

> (retroactive, sorry)
>
> This is a very very big precondition to add (that the object can be safely
> moved
> with memcpy), and one that doesn't seem to be compile-time checked or even
> commented.
>
> In Blink, Vector uses a traits struct (VectorTraits<T>::canMoveWithMemcpy,
> which
> ultimately defaults to __has_trivial_assign(T)). WDYT of me at least
> filing a
> bug to check this, since this could result in rather weird bugs if, for
> instance, a list container ever contained something that vends WeakPtrs.
>
> https://codereview.chromium.org/1202153002/
>

To unsubscribe from this group and stop receiving emails from it, send an email
to chromium-reviews+unsubscribe@chromium.org.

Powered by Google App Engine
This is Rietveld 408576698