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/user/cursor.cpp | 16 ++++++++-------- src/engine/user/cursor.hpp | 6 +++--- src/engine/user/input.cpp | 10 +++++----- src/engine/user/input.hpp | 12 ++++++------ 4 files changed, 22 insertions(+), 22 deletions(-) (limited to 'src/engine/user') 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 #include -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 { 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 -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 { 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> _key_observers; -- cgit v1.2.3-18-g5258