diff options
author | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-30 03:34:37 +0000 |
---|---|---|
committer | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-30 03:34:37 +0000 |
commit | 7e830a9541a0b76e5c929ad8b64dbf0620b58e00 (patch) | |
tree | bc75e35877859df8ee6bd3360b65e12cc2359efc /ui/gfx | |
parent | 8f9f3408ebc699966ffed35dd37392f75911b3ee (diff) | |
download | chromium_src-7e830a9541a0b76e5c929ad8b64dbf0620b58e00.zip chromium_src-7e830a9541a0b76e5c929ad8b64dbf0620b58e00.tar.gz chromium_src-7e830a9541a0b76e5c929ad8b64dbf0620b58e00.tar.bz2 |
Inline hot ctor/dtors for struct-like gfx:: geometry types
This inlines the ctors and (empty) dtors for gfx::PointF, SizeF and RectF. On
a ToT chromium mac release build, inlining these is a 8.5% speedup on cc_perftests.
Based on profiling data from instruments inlining QuadF would be a speedup as well,
but the chromium-style plugin thinks it's too complex (even though the dtor has no
code).
BUG=
NOTRY=true (yoda style)
Review URL: https://chromiumcodereview.appspot.com/11428076
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170378 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx')
-rw-r--r-- | ui/gfx/point.cc | 6 | ||||
-rw-r--r-- | ui/gfx/point.h | 4 | ||||
-rw-r--r-- | ui/gfx/point_f.cc | 8 | ||||
-rw-r--r-- | ui/gfx/point_f.h | 6 | ||||
-rw-r--r-- | ui/gfx/rect.cc | 21 | ||||
-rw-r--r-- | ui/gfx/rect.h | 23 | ||||
-rw-r--r-- | ui/gfx/rect_f.cc | 21 | ||||
-rw-r--r-- | ui/gfx/rect_f.h | 26 | ||||
-rw-r--r-- | ui/gfx/size.cc | 9 | ||||
-rw-r--r-- | ui/gfx/size.h | 6 | ||||
-rw-r--r-- | ui/gfx/size_f.cc | 9 | ||||
-rw-r--r-- | ui/gfx/size_f.h | 6 |
12 files changed, 48 insertions, 97 deletions
diff --git a/ui/gfx/point.cc b/ui/gfx/point.cc index e0b5595..35f4b44 100644 --- a/ui/gfx/point.cc +++ b/ui/gfx/point.cc @@ -14,12 +14,6 @@ namespace gfx { template class PointBase<Point, int, Vector2d>; -Point::Point() : PointBase<Point, int, Vector2d>(0, 0) { -} - -Point::Point(int x, int y) : PointBase<Point, int, Vector2d>(x, y) { -} - #if defined(OS_WIN) Point::Point(DWORD point) : PointBase<Point, int, Vector2d>(0, 0){ POINTS points = MAKEPOINTS(point); diff --git a/ui/gfx/point.h b/ui/gfx/point.h index 4404582..0f8a327 100644 --- a/ui/gfx/point.h +++ b/ui/gfx/point.h @@ -24,8 +24,8 @@ namespace gfx { // A point has an x and y coordinate. class UI_EXPORT Point : public PointBase<Point, int, Vector2d> { public: - Point(); - Point(int x, int y); + Point() : PointBase<Point, int, Vector2d>(0, 0) {} + Point(int x, int y) : PointBase<Point, int, Vector2d>(x, y) {} #if defined(OS_WIN) // |point| is a DWORD value that contains a coordinate. The x-coordinate is // the low-order short and the y-coordinate is the high-order short. This diff --git a/ui/gfx/point_f.cc b/ui/gfx/point_f.cc index ea683030..26080f5 100644 --- a/ui/gfx/point_f.cc +++ b/ui/gfx/point_f.cc @@ -10,14 +10,6 @@ namespace gfx { template class PointBase<PointF, float, Vector2dF>; -PointF::PointF() : PointBase<PointF, float, Vector2dF>(0, 0) { -} - -PointF::PointF(float x, float y) : PointBase<PointF, float, Vector2dF>(x, y) { -} - -PointF::~PointF() {} - std::string PointF::ToString() const { return base::StringPrintf("%f,%f", x(), y()); } diff --git a/ui/gfx/point_f.h b/ui/gfx/point_f.h index 7a828be..a7b841f 100644 --- a/ui/gfx/point_f.h +++ b/ui/gfx/point_f.h @@ -16,9 +16,9 @@ namespace gfx { // A floating version of gfx::Point. class UI_EXPORT PointF : public PointBase<PointF, float, Vector2dF> { public: - PointF(); - PointF(float x, float y); - ~PointF(); + PointF() : PointBase<PointF, float, Vector2dF>(0, 0) {} + PointF(float x, float y) : PointBase<PointF, float, Vector2dF>(x, y) {} + ~PointF() {} void Scale(float scale) { Scale(scale, scale); diff --git a/ui/gfx/rect.cc b/ui/gfx/rect.cc index 0fe3813..a562faf 100644 --- a/ui/gfx/rect.cc +++ b/ui/gfx/rect.cc @@ -23,27 +23,6 @@ template class RectBase<Rect, Point, Size, Insets, Vector2d, int>; typedef class RectBase<Rect, Point, Size, Insets, Vector2d, int> RectBaseT; -Rect::Rect() : RectBaseT(gfx::Point()) { -} - -Rect::Rect(int width, int height) - : RectBaseT(gfx::Size(width, height)) { -} - -Rect::Rect(int x, int y, int width, int height) - : RectBaseT(gfx::Point(x, y), gfx::Size(width, height)) { -} - -Rect::Rect(const gfx::Size& size) - : RectBaseT(size) { -} - -Rect::Rect(const gfx::Point& origin, const gfx::Size& size) - : RectBaseT(origin, size) { -} - -Rect::~Rect() {} - #if defined(OS_WIN) Rect::Rect(const RECT& r) : RectBaseT(gfx::Point(r.left, r.top)) { diff --git a/ui/gfx/rect.h b/ui/gfx/rect.h index 076f9fc..52856d7 100644 --- a/ui/gfx/rect.h +++ b/ui/gfx/rect.h @@ -37,9 +37,16 @@ class Insets; class UI_EXPORT Rect : public RectBase<Rect, Point, Size, Insets, Vector2d, int> { public: - Rect(); - Rect(int width, int height); - Rect(int x, int y, int width, int height); + Rect() : RectBase<Rect, Point, Size, Insets, Vector2d, int>(Point()) {} + + Rect(int width, int height) + : RectBase<Rect, Point, Size, Insets, Vector2d, int> + (Size(width, height)) {} + + Rect(int x, int y, int width, int height) + : RectBase<Rect, Point, Size, Insets, Vector2d, int> + (Point(x, y), Size(width, height)) {} + #if defined(OS_WIN) explicit Rect(const RECT& r); #elif defined(OS_MACOSX) @@ -47,10 +54,14 @@ class UI_EXPORT Rect #elif defined(TOOLKIT_GTK) explicit Rect(const GdkRectangle& r); #endif - explicit Rect(const gfx::Size& size); - Rect(const gfx::Point& origin, const gfx::Size& size); - ~Rect(); + explicit Rect(const gfx::Size& size) + : RectBase<Rect, Point, Size, Insets, Vector2d, int>(size) {} + + Rect(const gfx::Point& origin, const gfx::Size& size) + : RectBase<Rect, Point, Size, Insets, Vector2d, int>(origin, size) {} + + ~Rect() {} #if defined(OS_WIN) // Construct an equivalent Win32 RECT object. diff --git a/ui/gfx/rect_f.cc b/ui/gfx/rect_f.cc index 4413fb8..d7b1089 100644 --- a/ui/gfx/rect_f.cc +++ b/ui/gfx/rect_f.cc @@ -19,27 +19,6 @@ template class RectBase<RectF, PointF, SizeF, InsetsF, Vector2dF, float>; typedef class RectBase<RectF, PointF, SizeF, InsetsF, Vector2dF, float> RectBaseT; -RectF::RectF() : RectBaseT(gfx::SizeF()) { -} - -RectF::RectF(float width, float height) - : RectBaseT(gfx::SizeF(width, height)) { -} - -RectF::RectF(float x, float y, float width, float height) - : RectBaseT(gfx::PointF(x, y), gfx::SizeF(width, height)) { -} - -RectF::RectF(const gfx::SizeF& size) - : RectBaseT(size) { -} - -RectF::RectF(const gfx::PointF& origin, const gfx::SizeF& size) - : RectBaseT(origin, size) { -} - -RectF::~RectF() {} - bool RectF::IsExpressibleAsRect() const { return IsExpressibleAsInt(x()) && IsExpressibleAsInt(y()) && IsExpressibleAsInt(width()) && IsExpressibleAsInt(height()) && diff --git a/ui/gfx/rect_f.h b/ui/gfx/rect_f.h index 2bc367c..bbc16cc 100644 --- a/ui/gfx/rect_f.h +++ b/ui/gfx/rect_f.h @@ -20,13 +20,27 @@ class InsetsF; class UI_EXPORT RectF : public RectBase<RectF, PointF, SizeF, InsetsF, Vector2dF, float> { public: - RectF(); - RectF(float width, float height); - RectF(float x, float y, float width, float height); - explicit RectF(const gfx::SizeF& size); - RectF(const gfx::PointF& origin, const gfx::SizeF& size); + RectF() + : RectBase<RectF, PointF, SizeF, InsetsF, Vector2dF, float> + (SizeF()) {} - ~RectF(); + RectF(float width, float height) + : RectBase<RectF, PointF, SizeF, InsetsF, Vector2dF, float> + (SizeF(width, height)) {} + + RectF(float x, float y, float width, float height) + : RectBase<RectF, PointF, SizeF, InsetsF, Vector2dF, float> + (PointF(x, y), SizeF(width, height)) {} + + explicit RectF(const SizeF& size) + : RectBase<RectF, PointF, SizeF, InsetsF, Vector2dF, float> + (size) {} + + RectF(const PointF& origin, const SizeF& size) + : RectBase<RectF, PointF, SizeF, InsetsF, Vector2dF, float> + (origin, size) {} + + ~RectF() {} // Scales the rectangle by |scale|. void Scale(float scale) { diff --git a/ui/gfx/size.cc b/ui/gfx/size.cc index 6d28ded..a9a0bdd 100644 --- a/ui/gfx/size.cc +++ b/ui/gfx/size.cc @@ -16,13 +16,6 @@ namespace gfx { template class SizeBase<Size, int>; -Size::Size() : SizeBase<Size, int>(0, 0) {} - -Size::Size(int width, int height) : SizeBase<Size, int>(0, 0) { - set_width(width); - set_height(height); -} - #if defined(OS_MACOSX) Size::Size(const CGSize& s) : SizeBase<Size, int>(0, 0) { set_width(s.width); @@ -36,8 +29,6 @@ Size& Size::operator=(const CGSize& s) { } #endif -Size::~Size() {} - #if defined(OS_WIN) SIZE Size::ToSIZE() const { SIZE s; diff --git a/ui/gfx/size.h b/ui/gfx/size.h index edfc1fc..f6152a3 100644 --- a/ui/gfx/size.h +++ b/ui/gfx/size.h @@ -25,13 +25,13 @@ namespace gfx { // A size has width and height values. class UI_EXPORT Size : public SizeBase<Size, int> { public: - Size(); - Size(int width, int height); + Size() : SizeBase<Size, int>(0, 0) {} + Size(int width, int height) : SizeBase<Size, int>(width, height) {} #if defined(OS_MACOSX) explicit Size(const CGSize& s); #endif - ~Size(); + ~Size() {} #if defined(OS_MACOSX) Size& operator=(const CGSize& s); diff --git a/ui/gfx/size_f.cc b/ui/gfx/size_f.cc index 03c34ec..69e0ee9 100644 --- a/ui/gfx/size_f.cc +++ b/ui/gfx/size_f.cc @@ -11,15 +11,6 @@ namespace gfx { template class SizeBase<SizeF, float>; -SizeF::SizeF() : SizeBase<SizeF, float>(0, 0) {} - -SizeF::SizeF(float width, float height) : SizeBase<SizeF, float>(0, 0) { - set_width(width); - set_height(height); -} - -SizeF::~SizeF() {} - std::string SizeF::ToString() const { return base::StringPrintf("%fx%f", width(), height()); } diff --git a/ui/gfx/size_f.h b/ui/gfx/size_f.h index 98d2e0c..a38d3f6 100644 --- a/ui/gfx/size_f.h +++ b/ui/gfx/size_f.h @@ -16,9 +16,9 @@ namespace gfx { // A floating version of gfx::Size. class UI_EXPORT SizeF : public SizeBase<SizeF, float> { public: - SizeF(); - SizeF(float width, float height); - ~SizeF(); + SizeF() : SizeBase<SizeF, float>(0, 0) {} + SizeF(float width, float height) : SizeBase<SizeF, float>(width, height) {} + ~SizeF() {} void Scale(float scale) { Scale(scale, scale); |