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/user | |
parent | dbab54ebf134b6ab2cf719d7c26a191fbffeed34 (diff) |
perf: add noexcept almost everywhere
Diffstat (limited to 'src/engine/user')
-rw-r--r-- | src/engine/user/cursor.cpp | 16 | ||||
-rw-r--r-- | src/engine/user/cursor.hpp | 6 | ||||
-rw-r--r-- | src/engine/user/input.cpp | 10 | ||||
-rw-r--r-- | src/engine/user/input.hpp | 12 |
4 files changed, 22 insertions, 22 deletions
diff --git a/src/engine/user/cursor.cpp b/src/engine/user/cursor.cpp index 663d56a..b02a9bc 100644 --- a/src/engine/user/cursor.cpp +++ b/src/engine/user/cursor.cpp @@ -5,7 +5,7 @@ #include <cstdlib> #include <iostream> -CursorController::CursorController() : _position({.x = 0, .y = 0}) {} +CursorController::CursorController() noexcept : _position({.x = 0, .y = 0}) {} void CursorController::move(const Vector2 &direction, const uint32_t &amount) noexcept { @@ -32,12 +32,6 @@ Vector2 CursorController::where() const noexcept return _position; } -void CursorController::hide() -{ - fmt::print(CURSOR_INVISIBLE, fmt::arg("esc", ESC)); - std::cout.flush(); -} - void CursorController::ensure_position() noexcept { fmt::print(REQUEST_CURSOR_POSITION, fmt::arg("esc", ESC)); @@ -51,7 +45,13 @@ void CursorController::ensure_position() noexcept _position = Vector2(vector2_options); } -void CursorController::show() +void CursorController::hide() noexcept +{ + fmt::print(CURSOR_INVISIBLE, fmt::arg("esc", ESC)); + std::cout.flush(); +} + +void CursorController::show() noexcept { fmt::print(CURSOR_VISIBLE, fmt::arg("esc", ESC)); std::cout.flush(); diff --git a/src/engine/user/cursor.hpp b/src/engine/user/cursor.hpp index c591235..713ee31 100644 --- a/src/engine/user/cursor.hpp +++ b/src/engine/user/cursor.hpp @@ -33,7 +33,7 @@ class CursorController : public ICursorController, public AutoWirable<ICursorController, CursorController> { public: - CursorController(); + CursorController() noexcept; void move(const Vector2 &direction, const uint32_t &amount) noexcept override; @@ -43,9 +43,9 @@ public: void ensure_position() noexcept override; - static void hide(); + static void hide() noexcept; - static void show(); + static void show() noexcept; private: Vector2 _position; diff --git a/src/engine/user/input.cpp b/src/engine/user/input.cpp index 1dc7f63..62aef67 100644 --- a/src/engine/user/input.cpp +++ b/src/engine/user/input.cpp @@ -2,7 +2,7 @@ #include <unistd.h> -void InputHandler::listen() const +void InputHandler::listen() const noexcept { char character = 0; @@ -12,7 +12,7 @@ void InputHandler::listen() const } } -void InputHandler::attach(const char &event, Callback callback) +void InputHandler::attach(const char &event, Callback callback) noexcept { if (_key_observers.count(event) == 0) { @@ -22,7 +22,7 @@ void InputHandler::attach(const char &event, Callback callback) _key_observers[event].push_back(callback); } -void InputHandler::notify(const char &event) const +void InputHandler::notify(const char &event) const noexcept { if (_key_observers.count(event) == 0) { @@ -35,7 +35,7 @@ void InputHandler::notify(const char &event) const } } -void InputHandler::enter_raw_mode() +void InputHandler::enter_raw_mode() noexcept { if (_original_termios == nullptr) { @@ -51,7 +51,7 @@ void InputHandler::enter_raw_mode() tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw_termios); } -void InputHandler::leave_raw_mode() +void InputHandler::leave_raw_mode() noexcept { if (_original_termios == nullptr) { diff --git a/src/engine/user/input.hpp b/src/engine/user/input.hpp index f48ab86..3dd7fa9 100644 --- a/src/engine/user/input.hpp +++ b/src/engine/user/input.hpp @@ -12,17 +12,17 @@ class InputHandler : public IInputHandler, public AutoWirable<IInputHandler, InputHandler> { public: - InputHandler() = default; + InputHandler() noexcept = default; - void listen() const override; + void listen() const noexcept override; - void attach(const char &event, Callback callback) override; + void attach(const char &event, Callback callback) noexcept override; - void notify(const char &event) const override; + void notify(const char &event) const noexcept override; - void enter_raw_mode() override; + void enter_raw_mode() noexcept override; - void leave_raw_mode() override; + void leave_raw_mode() noexcept override; private: std::unordered_map<char, std::vector<Callback>> _key_observers; |