From 4e513a15d07e0877a4688458ce0e28fbe5d70b31 Mon Sep 17 00:00:00 2001 From: Pharap <2933055+Pharap@users.noreply.github.com> Date: Fri, 21 Feb 2020 18:18:15 +0000 Subject: [PATCH] Make Rect and Point's constructors constexpr --- src/Arduboy2.cpp | 18 ------------------ src/Arduboy2.h | 10 ++++++++-- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/src/Arduboy2.cpp b/src/Arduboy2.cpp index abe4cb4..8f4cb07 100644 --- a/src/Arduboy2.cpp +++ b/src/Arduboy2.cpp @@ -8,24 +8,6 @@ #include "ab_logo.c" #include "glcdfont.c" -//================================ -//========== class Rect ========== -//================================ - -Rect::Rect(int16_t x, int16_t y, uint8_t width, uint8_t height) - : x(x), y(y), width(width), height(height) -{ -} - -//================================= -//========== class Point ========== -//================================= - -Point::Point(int16_t x, int16_t y) - : x(x), y(y) -{ -} - //======================================== //========== class Arduboy2Base ========== //======================================== diff --git a/src/Arduboy2.h b/src/Arduboy2.h index b3c420a..032a089 100644 --- a/src/Arduboy2.h +++ b/src/Arduboy2.h @@ -122,7 +122,10 @@ struct Rect * \param width The width of the rectangle. Copied to variable `width`. * \param height The height of the rectangle. Copied to variable `height`. */ - Rect(int16_t x, int16_t y, uint8_t width, uint8_t height); + constexpr Rect(int16_t x, int16_t y, uint8_t width, uint8_t height) + : x(x), y(y), width(width), height(height) + { + } }; //================================== @@ -153,7 +156,10 @@ struct Point * \param x The X coordinate of the point. Copied to variable `x`. * \param y The Y coordinate of the point. Copied to variable `y`. */ - Point(int16_t x, int16_t y); + constexpr Point(int16_t x, int16_t y) + : x(x), y(y) + { + } }; //==================================