summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvmpstr <vmpstr@chromium.org>2016-01-07 16:19:35 -0800
committerCommit bot <commit-bot@chromium.org>2016-01-08 00:20:26 +0000
commitab0c1304c9f3b0c248f154680db5449f1a5497c8 (patch)
treef62e5ac650bcf87d3274a7fe75862bbda79ad7ed
parentcf4cad0723200734c283dae2d0c92a88054713f6 (diff)
downloadchromium_src-ab0c1304c9f3b0c248f154680db5449f1a5497c8.zip
chromium_src-ab0c1304c9f3b0c248f154680db5449f1a5497c8.tar.gz
chromium_src-ab0c1304c9f3b0c248f154680db5449f1a5497c8.tar.bz2
cc: Use std::forward for forwarding arguments.
Now that forward is allowed, this patch changes the places that had a TODO to actually using perfect forwarding. R=enne CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1568533007 Cr-Commit-Position: refs/heads/master@{#368211}
-rw-r--r--cc/base/contiguous_container.h7
-rw-r--r--cc/playback/display_item_list.h7
2 files changed, 8 insertions, 6 deletions
diff --git a/cc/base/contiguous_container.h b/cc/base/contiguous_container.h
index bad1511..af82b7e 100644
--- a/cc/base/contiguous_container.h
+++ b/cc/base/contiguous_container.h
@@ -6,6 +6,7 @@
#define CC_BASE_CONTIGUOUS_CONTAINER_H_
#include <stddef.h>
+#include <utility>
#include "base/logging.h"
#include "base/macros.h"
@@ -164,12 +165,12 @@ class ContiguousContainer : public ContiguousContainerBase {
}
template <class DerivedElementType, typename... Args>
- DerivedElementType& AllocateAndConstruct(const Args&... args) {
+ DerivedElementType& AllocateAndConstruct(Args&&... args) {
static_assert(alignment % ALIGNOF(DerivedElementType) == 0,
"Derived type requires stronger alignment.");
size_t alloc_size = Align(sizeof(DerivedElementType));
- // TODO(enne): This should forward the args.
- return *new (Allocate(alloc_size)) DerivedElementType(args...);
+ return *new (Allocate(alloc_size))
+ DerivedElementType(std::forward<Args>(args)...);
}
void RemoveLast() {
diff --git a/cc/playback/display_item_list.h b/cc/playback/display_item_list.h
index 28a2d2c..bcad05c 100644
--- a/cc/playback/display_item_list.h
+++ b/cc/playback/display_item_list.h
@@ -6,6 +6,7 @@
#define CC_PLAYBACK_DISPLAY_ITEM_LIST_H_
#include <stddef.h>
+#include <utility>
#include "base/gtest_prod_util.h"
#include "base/macros.h"
@@ -70,10 +71,10 @@ class CC_EXPORT DisplayItemList
// type needs to be const, to prevent set-after-processing mistakes.
template <typename DisplayItemType, typename... Args>
const DisplayItemType& CreateAndAppendItem(const gfx::Rect& visual_rect,
- const Args&... args) {
+ Args&&... args) {
visual_rects_.push_back(visual_rect);
- // TODO(enne): This should forward the args.
- auto* item = &items_.AllocateAndConstruct<DisplayItemType>(args...);
+ auto* item = &items_.AllocateAndConstruct<DisplayItemType>(
+ std::forward<Args>(args)...);
approximate_op_count_ += item->ApproximateOpCount();
// TODO(crbug.com/513016): None of the items might individually trigger a
// veto even though they collectively have enough "bad" operations that a