Pass gfx structs by const ref (gfx::Vector2dF)
Avoid unneccessary copy of structures gfx::Vector2dF
by passing them by const ref rather than value.
Any struct of size > 4 bytes should be passed by const ref.
Passing by ref for these structs is faster than passing
by value, especially when invoking function has multiple parameters.
Pass gfx structs by const ref (gfx::Vector2dF)
BUG=159273
Review URL: https://codereview.chromium.org/130443005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@246563 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/cc/layers/layer_impl.cc b/cc/layers/layer_impl.cc
index a783a78..7444b779 100644
--- a/cc/layers/layer_impl.cc
+++ b/cc/layers/layer_impl.cc
@@ -376,7 +376,7 @@
sent_scroll_delta_ = sent_scroll_delta;
}
-gfx::Vector2dF LayerImpl::ScrollBy(gfx::Vector2dF scroll) {
+gfx::Vector2dF LayerImpl::ScrollBy(const gfx::Vector2dF& scroll) {
DCHECK(scrollable());
gfx::Vector2dF min_delta = -scroll_offset_;
gfx::Vector2dF max_delta = max_scroll_offset_ - scroll_offset_;
@@ -731,7 +731,7 @@
SetTransform(transform);
}
-void LayerImpl::OnScrollOffsetAnimated(gfx::Vector2dF scroll_offset) {
+void LayerImpl::OnScrollOffsetAnimated(const gfx::Vector2dF& scroll_offset) {
// Only layers in the active tree should need to do anything here, since
// layers in the pending tree will find out about these changes as a
// result of the call to SetScrollDelta.
@@ -1092,7 +1092,7 @@
}
void LayerImpl::SetScrollOffsetAndDelta(gfx::Vector2d scroll_offset,
- gfx::Vector2dF scroll_delta) {
+ const gfx::Vector2dF& scroll_delta) {
bool changed = false;
if (scroll_offset_ != scroll_offset) {
@@ -1139,7 +1139,7 @@
return scroll_delta_;
}
-void LayerImpl::SetScrollDelta(gfx::Vector2dF scroll_delta) {
+void LayerImpl::SetScrollDelta(const gfx::Vector2dF& scroll_delta) {
SetScrollOffsetAndDelta(scroll_offset_, scroll_delta);
}