From dc6222611ad14a33f642396558ba84ecba9d6605 Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 14 Mar 2022 18:02:18 +0100 Subject: perf: add noexcept almost everywhere --- src/engine/data/vector2.hpp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'src/engine/data/vector2.hpp') diff --git a/src/engine/data/vector2.hpp b/src/engine/data/vector2.hpp index e835e65..868394a 100644 --- a/src/engine/data/vector2.hpp +++ b/src/engine/data/vector2.hpp @@ -17,7 +17,10 @@ class Vector2 public: using Value = int32_t; - explicit Vector2(const Vector2Options &options); + constexpr explicit Vector2(const Vector2Options &options) noexcept + : _x(options.x), _y(options.y) + { + } [[nodiscard]] Value get_x() const noexcept; @@ -41,22 +44,35 @@ public: /** * Returns Vector2({.x = 0, .y = -1}) */ - static Vector2 up() noexcept; + static constexpr Vector2 up() noexcept + { + return Vector2({.x = 0, .y = -1}); + } /** * Returns Vector2({.x = 0, .y = 1}) */ - static Vector2 down() noexcept; + static constexpr Vector2 down() noexcept + { + return Vector2({.x = 0, .y = 1}); + } /** * Returns Vector2({.x = -1, .y = 0}) */ - static Vector2 left() noexcept; + static constexpr Vector2 left() noexcept + { + + return Vector2({.x = -1, .y = 0}); + } /** * Returns Vector2({.x = 1, .y = 0}) */ - static Vector2 right() noexcept; + static constexpr Vector2 right() noexcept + { + return Vector2({.x = 1, .y = 0}); + } private: Value _x; -- cgit v1.2.3-18-g5258