diff options
author | HampusM <hampus@hampusmat.com> | 2022-03-14 18:02:18 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-06-13 17:56:56 +0200 |
commit | dc6222611ad14a33f642396558ba84ecba9d6605 (patch) | |
tree | d759020233b66be62c5539209a03842d283b67a9 /src/engine/data/vector2.hpp | |
parent | dbab54ebf134b6ab2cf719d7c26a191fbffeed34 (diff) |
perf: add noexcept almost everywhere
Diffstat (limited to 'src/engine/data/vector2.hpp')
-rw-r--r-- | src/engine/data/vector2.hpp | 26 |
1 files changed, 21 insertions, 5 deletions
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; |