diff options
author | prashant.n@samsung.com <prashant.n@samsung.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-28 06:37:17 +0000 |
---|---|---|
committer | prashant.n@samsung.com <prashant.n@samsung.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-28 06:37:17 +0000 |
commit | c93cbb62f684183e0e5689a9fa35619daac10f7b (patch) | |
tree | 8002e049a31ad5cad79f63d19fe1f79b68b8ae2f /cc/base | |
parent | 22a9610ffaed4d7690463d2f6f710d46c206c70f (diff) | |
download | chromium_src-c93cbb62f684183e0e5689a9fa35619daac10f7b.zip chromium_src-c93cbb62f684183e0e5689a9fa35619daac10f7b.tar.gz chromium_src-c93cbb62f684183e0e5689a9fa35619daac10f7b.tar.bz2 |
[#7] Pass gfx::Size by const ref.
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 and some
other scenarios mentioned in the bug.
BUG=159273
Review URL: https://codereview.chromium.org/145313006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@247426 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/base')
-rw-r--r-- | cc/base/math_util.cc | 2 | ||||
-rw-r--r-- | cc/base/math_util.h | 2 | ||||
-rw-r--r-- | cc/base/tiling_data.cc | 12 | ||||
-rw-r--r-- | cc/base/tiling_data.h | 12 | ||||
-rw-r--r-- | cc/base/tiling_data_unittest.cc | 44 |
5 files changed, 36 insertions, 36 deletions
diff --git a/cc/base/math_util.cc b/cc/base/math_util.cc index 8abfa90f0..72b1e7f 100644 --- a/cc/base/math_util.cc +++ b/cc/base/math_util.cc @@ -508,7 +508,7 @@ gfx::Vector2dF MathUtil::ProjectVector(const gfx::Vector2dF& source, projected_length * destination.y()); } -scoped_ptr<base::Value> MathUtil::AsValue(gfx::Size s) { +scoped_ptr<base::Value> MathUtil::AsValue(const gfx::Size& s) { scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue()); res->SetDouble("width", s.width()); res->SetDouble("height", s.height()); diff --git a/cc/base/math_util.h b/cc/base/math_util.h index 6cad1ad..fca08ef 100644 --- a/cc/base/math_util.h +++ b/cc/base/math_util.h @@ -165,7 +165,7 @@ class CC_EXPORT MathUtil { const gfx::Vector2dF& destination); // Conversion to value. - static scoped_ptr<base::Value> AsValue(gfx::Size s); + static scoped_ptr<base::Value> AsValue(const gfx::Size& s); static scoped_ptr<base::Value> AsValue(const gfx::SizeF& s); static scoped_ptr<base::Value> AsValue(const gfx::Rect& r); static bool FromValue(const base::Value*, gfx::Rect* out_rect); diff --git a/cc/base/tiling_data.cc b/cc/base/tiling_data.cc index 9cdf027..8b3ba62 100644 --- a/cc/base/tiling_data.cc +++ b/cc/base/tiling_data.cc @@ -29,8 +29,8 @@ TilingData::TilingData() } TilingData::TilingData( - gfx::Size max_texture_size, - gfx::Size total_size, + const gfx::Size& max_texture_size, + const gfx::Size& total_size, bool has_border_texels) : max_texture_size_(max_texture_size), total_size_(total_size), @@ -39,8 +39,8 @@ TilingData::TilingData( } TilingData::TilingData( - gfx::Size max_texture_size, - gfx::Size total_size, + const gfx::Size& max_texture_size, + const gfx::Size& total_size, int border_texels) : max_texture_size_(max_texture_size), total_size_(total_size), @@ -48,12 +48,12 @@ TilingData::TilingData( RecomputeNumTiles(); } -void TilingData::SetTotalSize(gfx::Size total_size) { +void TilingData::SetTotalSize(const gfx::Size& total_size) { total_size_ = total_size; RecomputeNumTiles(); } -void TilingData::SetMaxTextureSize(gfx::Size max_texture_size) { +void TilingData::SetMaxTextureSize(const gfx::Size& max_texture_size) { max_texture_size_ = max_texture_size; RecomputeNumTiles(); } diff --git a/cc/base/tiling_data.h b/cc/base/tiling_data.h index 96e6ae0..9540c38 100644 --- a/cc/base/tiling_data.h +++ b/cc/base/tiling_data.h @@ -23,19 +23,19 @@ class CC_EXPORT TilingData { public: TilingData(); TilingData( - gfx::Size max_texture_size, - gfx::Size total_size, + const gfx::Size& max_texture_size, + const gfx::Size& total_size, bool has_border_texels); TilingData( - gfx::Size max_texture_size, - gfx::Size total_size, + const gfx::Size& max_texture_size, + const gfx::Size& total_size, int border_texels); gfx::Size total_size() const { return total_size_; } - void SetTotalSize(const gfx::Size total_size); + void SetTotalSize(const gfx::Size& total_size); gfx::Size max_texture_size() const { return max_texture_size_; } - void SetMaxTextureSize(gfx::Size max_texture_size); + void SetMaxTextureSize(const gfx::Size& max_texture_size); int border_texels() const { return border_texels_; } void SetHasBorderTexels(bool has_border_texels); diff --git a/cc/base/tiling_data_unittest.cc b/cc/base/tiling_data_unittest.cc index db2d6f2..55b3b6d 100644 --- a/cc/base/tiling_data_unittest.cc +++ b/cc/base/tiling_data_unittest.cc @@ -13,8 +13,8 @@ namespace cc { namespace { int NumTiles( - gfx::Size max_texture_size, - gfx::Size total_size, + const gfx::Size& max_texture_size, + const gfx::Size& total_size, bool has_border_texels) { TilingData tiling(max_texture_size, total_size, has_border_texels); int num_tiles = tiling.num_tiles_x() * tiling.num_tiles_y(); @@ -28,8 +28,8 @@ int NumTiles( } int XIndex( - gfx::Size max_texture_size, - gfx::Size total_size, + const gfx::Size& max_texture_size, + const gfx::Size& total_size, bool has_border_texels, int x_coord) { TilingData tiling(max_texture_size, total_size, has_border_texels); @@ -37,8 +37,8 @@ int XIndex( } int YIndex( - gfx::Size max_texture_size, - gfx::Size total_size, + const gfx::Size& max_texture_size, + const gfx::Size& total_size, bool has_border_texels, int y_coord) { TilingData tiling(max_texture_size, total_size, has_border_texels); @@ -46,8 +46,8 @@ int YIndex( } int MinBorderXIndex( - gfx::Size max_texture_size, - gfx::Size total_size, + const gfx::Size& max_texture_size, + const gfx::Size& total_size, bool has_border_texels, int x_coord) { TilingData tiling(max_texture_size, total_size, has_border_texels); @@ -55,8 +55,8 @@ int MinBorderXIndex( } int MinBorderYIndex( - gfx::Size max_texture_size, - gfx::Size total_size, + const gfx::Size& max_texture_size, + const gfx::Size& total_size, bool has_border_texels, int y_coord) { TilingData tiling(max_texture_size, total_size, has_border_texels); @@ -64,8 +64,8 @@ int MinBorderYIndex( } int MaxBorderXIndex( - gfx::Size max_texture_size, - gfx::Size total_size, + const gfx::Size& max_texture_size, + const gfx::Size& total_size, bool has_border_texels, int x_coord) { TilingData tiling(max_texture_size, total_size, has_border_texels); @@ -73,8 +73,8 @@ int MaxBorderXIndex( } int MaxBorderYIndex( - gfx::Size max_texture_size, - gfx::Size total_size, + const gfx::Size& max_texture_size, + const gfx::Size& total_size, bool has_border_texels, int y_coord) { TilingData tiling(max_texture_size, total_size, has_border_texels); @@ -82,8 +82,8 @@ int MaxBorderYIndex( } int PosX( - gfx::Size max_texture_size, - gfx::Size total_size, + const gfx::Size& max_texture_size, + const gfx::Size& total_size, bool has_border_texels, int x_index) { TilingData tiling(max_texture_size, total_size, has_border_texels); @@ -91,8 +91,8 @@ int PosX( } int PosY( - gfx::Size max_texture_size, - gfx::Size total_size, + const gfx::Size& max_texture_size, + const gfx::Size& total_size, bool has_border_texels, int y_index) { TilingData tiling(max_texture_size, total_size, has_border_texels); @@ -100,8 +100,8 @@ int PosY( } int SizeX( - gfx::Size max_texture_size, - gfx::Size total_size, + const gfx::Size& max_texture_size, + const gfx::Size& total_size, bool has_border_texels, int x_index) { TilingData tiling(max_texture_size, total_size, has_border_texels); @@ -109,8 +109,8 @@ int SizeX( } int SizeY( - gfx::Size max_texture_size, - gfx::Size total_size, + const gfx::Size& max_texture_size, + const gfx::Size& total_size, bool has_border_texels, int y_index) { TilingData tiling(max_texture_size, total_size, has_border_texels); |