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

Unified Diff: cc/base/list_container.h

Issue 1219753003: Change ListContainer::AppendByMoving to return a pointer to the new item (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | cc/base/list_container_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/base/list_container.h
diff --git a/cc/base/list_container.h b/cc/base/list_container.h
index a9444cd03aa08d1e1192e625198e8222dae0ce36..7cccc6707c4e67ad51af61e045119eace5866ffb 100644
--- a/cc/base/list_container.h
+++ b/cc/base/list_container.h
@@ -296,14 +296,16 @@ class ListContainer : public ListContainerBase {
// Appends a new item without copying. The original item will not be
// destructed and will be replaced with a new DerivedElementType. The
// DerivedElementType does not have to match the moved type as a full block
- // of memory will be moved (up to MaxSizeForDerivedClass()).
+ // of memory will be moved (up to MaxSizeForDerivedClass()). A pointer to
+ // the moved element is returned.
template <typename DerivedElementType>
- void AppendByMoving(DerivedElementType* item) {
+ DerivedElementType* AppendByMoving(DerivedElementType* item) {
size_t max_size_for_derived_class = MaxSizeForDerivedClass();
void* new_item = Allocate(max_size_for_derived_class);
memcpy(new_item, static_cast<void*>(item), max_size_for_derived_class);
// Construct a new element in-place so it can be destructed safely.
new (item) DerivedElementType;
+ return static_cast<DerivedElementType*>(new_item);
}
using ListContainerBase::size;
« no previous file with comments | « no previous file | cc/base/list_container_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698