From 63cd8feebc7ccd3cce16526b9278af8db6f1203a Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Tue, 7 Jul 2015 15:28:16 +0300 Subject: [PATCH] Move most other Point methods to the header to allow inlining --- SDL2pp/Point.cc | 66 ------------------------------------------------- SDL2pp/Point.hh | 62 +++++++++++++++++++++++++++++++++++++--------- 2 files changed, 50 insertions(+), 78 deletions(-) diff --git a/SDL2pp/Point.cc b/SDL2pp/Point.cc index 64269ed..09d924f 100644 --- a/SDL2pp/Point.cc +++ b/SDL2pp/Point.cc @@ -25,72 +25,6 @@ namespace SDL2pp { -Point& Point::SetX(int nx) { - x = nx; - return *this; -} - -Point& Point::SetY(int ny) { - y = ny; - return *this; -} - -Point& Point::operator+=(const Point& other) { - x += other.x; - y += other.y; - - return *this; -} - -Point& Point::operator-=(const Point& other) { - x -= other.x; - y -= other.y; - - return *this; -} - -Point& Point::operator/=(int value) { - x /= value; - y /= value; - - return *this; -} - -Point& Point::operator/=(const Point& other) { - x /= other.x; - y /= other.y; - - return *this; -} - -Point& Point::operator%=(int value) { - x %= value; - y %= value; - - return *this; -} - -Point& Point::operator%=(const Point& other) { - x %= other.x; - y %= other.y; - - return *this; -} - -Point& Point::operator*=(int value) { - x *= value; - y *= value; - - return *this; -} - -Point& Point::operator*=(const Point& other) { - x *= other.x; - y *= other.y; - - return *this; -} - Point Point::GetClamped(const Rect& rect) const { Point p = *this; p.Clamp(rect); diff --git a/SDL2pp/Point.hh b/SDL2pp/Point.hh index 1949b8f..1fd8eda 100644 --- a/SDL2pp/Point.hh +++ b/SDL2pp/Point.hh @@ -145,7 +145,10 @@ public: /// \returns Reference to self /// //////////////////////////////////////////////////////////// - Point& SetX(int nx); + Point& SetX(int nx) { + x = nx; + return *this; + } //////////////////////////////////////////////////////////// /// \brief Get Y coordinate of the point @@ -165,7 +168,10 @@ public: /// \returns Reference to self /// //////////////////////////////////////////////////////////// - Point& SetY(int ny); + Point& SetY(int ny) { + y = ny; + return *this; + } //////////////////////////////////////////////////////////// /// \brief Get point's memberwise negation @@ -291,7 +297,11 @@ public: /// \returns Reference to self /// //////////////////////////////////////////////////////////// - Point& operator+=(const Point& other); + Point& operator+=(const Point& other) { + x += other.x; + y += other.y; + return *this; + } //////////////////////////////////////////////////////////// /// \brief Memberwise subtract another point @@ -301,7 +311,11 @@ public: /// \returns Reference to self /// //////////////////////////////////////////////////////////// - Point& operator-=(const Point& other); + Point& operator-=(const Point& other) { + x -= other.x; + y -= other.y; + return *this; + } //////////////////////////////////////////////////////////// /// \brief Memberwise divide by an integer @@ -311,17 +325,25 @@ public: /// \returns Reference to self /// //////////////////////////////////////////////////////////// - Point& operator/=(int value); + Point& operator/=(int value) { + x /= value; + y /= value; + return *this; + } - //////////////////////////////////////////////////////////// - /// \brief Memberwise divide by another point + /////////////////////////////////////////////////////////// + /// nbrief Memberwise divide by another point /// /// \param[in] other Divisor /// /// \returns Reference to self /// //////////////////////////////////////////////////////////// - Point& operator/=(const Point& other); + Point& operator/=(const Point& other) { + x /= other.x; + y /= other.y; + return *this; + } //////////////////////////////////////////////////////////// /// \brief Memberwise remainder from division by an integer @@ -331,7 +353,11 @@ public: /// \returns Reference to self /// //////////////////////////////////////////////////////////// - Point& operator%=(int value); + Point& operator%=(int value) { + x %= value; + y %= value; + return *this; + } //////////////////////////////////////////////////////////// /// \brief Memberwise remainder from division by another @@ -342,7 +368,11 @@ public: /// \returns Reference to self /// //////////////////////////////////////////////////////////// - Point& operator%=(const Point& other); + Point& operator%=(const Point& other) { + x %= other.x; + y %= other.y; + return *this; + } //////////////////////////////////////////////////////////// /// \brief Memberwise multiply by an integer @@ -352,7 +382,11 @@ public: /// \returns Reference to self /// //////////////////////////////////////////////////////////// - Point& operator*=(int value); + Point& operator*=(int value) { + x *= value; + y *= value; + return *this; + } //////////////////////////////////////////////////////////// /// \brief Memberwise multiply by another point @@ -362,7 +396,11 @@ public: /// \returns Reference to self /// //////////////////////////////////////////////////////////// - Point& operator*=(const Point& other); + Point& operator*=(const Point& other) { + x *= other.x; + y *= other.y; + return *this; + } //////////////////////////////////////////////////////////// /// \brief Get a point with coordinates modified so it fits