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/graphics | |
parent | dbab54ebf134b6ab2cf719d7c26a191fbffeed34 (diff) |
perf: add noexcept almost everywhere
Diffstat (limited to 'src/engine/graphics')
-rw-r--r-- | src/engine/graphics/scene.cpp | 2 | ||||
-rw-r--r-- | src/engine/graphics/string_matrix.cpp | 12 | ||||
-rw-r--r-- | src/engine/graphics/string_matrix.hpp | 12 |
3 files changed, 13 insertions, 13 deletions
diff --git a/src/engine/graphics/scene.cpp b/src/engine/graphics/scene.cpp index 6b85915..660e3ca 100644 --- a/src/engine/graphics/scene.cpp +++ b/src/engine/graphics/scene.cpp @@ -53,7 +53,7 @@ void Scene::write_status(const std::string_view &str) noexcept _cursor_controller->move_to( Vector2({.x = 2, .y = static_cast<Vector2::Value>(window_size.get_height())})); - const auto background_color = get_background_esc_seq(STATUSBAR_COLOR); + auto background_color = get_background_esc_seq(STATUSBAR_COLOR); fmt::print("{}", background_color); fmt::print(ERASE_ENTIRE_LINE, fmt::arg("esc", ESC)); diff --git a/src/engine/graphics/string_matrix.cpp b/src/engine/graphics/string_matrix.cpp index 26d48df..ae06755 100644 --- a/src/engine/graphics/string_matrix.cpp +++ b/src/engine/graphics/string_matrix.cpp @@ -1,13 +1,13 @@ #include "string_matrix.hpp" -StringMatrix::StringMatrix(const Bounds &bounds) +StringMatrix::StringMatrix(const Bounds &bounds) noexcept : _rows(bounds.get_height()), _columns(bounds.get_width()) { _matrix.reserve(bounds.get_height()); _matrix.assign(_matrix.capacity(), std::vector<std::string_view>(bounds.get_width())); }; -void StringMatrix::fill(std::string_view element) +void StringMatrix::fill(std::string_view element) noexcept { for (uint32_t row = 0U; row < _matrix.capacity(); row++) { @@ -20,7 +20,7 @@ void StringMatrix::fill(std::string_view element) } } -std::string_view StringMatrix::get(const Vector2 &pos) const +std::string_view StringMatrix::get(const Vector2 &pos) const noexcept { auto x = static_cast<std::size_t>(pos.get_x()); auto y = static_cast<std::size_t>(pos.get_y()); @@ -28,7 +28,7 @@ std::string_view StringMatrix::get(const Vector2 &pos) const return _matrix[y][x]; } -void StringMatrix::set(const Vector2 &pos, std::string_view element) +void StringMatrix::set(const Vector2 &pos, std::string_view element) noexcept { auto x = static_cast<std::size_t>(pos.get_x()); auto y = static_cast<std::size_t>(pos.get_y()); @@ -36,12 +36,12 @@ void StringMatrix::set(const Vector2 &pos, std::string_view element) _matrix[y][x] = element; } -uint32_t StringMatrix::rows() const +uint32_t StringMatrix::rows() const noexcept { return _rows; } -uint32_t StringMatrix::columns() const +uint32_t StringMatrix::columns() const noexcept { return _columns; } diff --git a/src/engine/graphics/string_matrix.hpp b/src/engine/graphics/string_matrix.hpp index 540d63b..40fbb11 100644 --- a/src/engine/graphics/string_matrix.hpp +++ b/src/engine/graphics/string_matrix.hpp @@ -19,21 +19,21 @@ public: * * @param bounds The bounds of the matrix */ - explicit StringMatrix(const Bounds &bounds); + explicit StringMatrix(const Bounds &bounds) noexcept; /** * Fills the matrix with a element. * * @param element A element */ - void fill(std::string_view element) override; + void fill(std::string_view element) noexcept override; /** * Returns a element of the matrix. * * @param pos The position of a element */ - [[nodiscard]] std::string_view get(const Vector2 &pos) const override; + [[nodiscard]] std::string_view get(const Vector2 &pos) const noexcept override; /** * Sets a element of the matrix. @@ -41,17 +41,17 @@ public: * @param pos The position of a element * @param element A new element */ - void set(const Vector2 &pos, std::string_view element) override; + void set(const Vector2 &pos, std::string_view element) noexcept override; /** * Returns the number of rows the matrix has. */ - [[nodiscard]] uint32_t rows() const override; + [[nodiscard]] uint32_t rows() const noexcept override; /** * Returns the number of columns the matrix has. */ - [[nodiscard]] uint32_t columns() const override; + [[nodiscard]] uint32_t columns() const noexcept override; private: std::vector<std::vector<std::string_view>> _matrix; |