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/randomization | |
parent | dbab54ebf134b6ab2cf719d7c26a191fbffeed34 (diff) |
perf: add noexcept almost everywhere
Diffstat (limited to 'src/randomization')
-rw-r--r-- | src/randomization/generator.cpp | 5 | ||||
-rw-r--r-- | src/randomization/generator.hpp | 5 | ||||
-rw-r--r-- | src/randomization/seed_generator.cpp | 5 | ||||
-rw-r--r-- | src/randomization/seed_generator.hpp | 5 |
4 files changed, 12 insertions, 8 deletions
diff --git a/src/randomization/generator.cpp b/src/randomization/generator.cpp index 56fbbf1..6956eda 100644 --- a/src/randomization/generator.cpp +++ b/src/randomization/generator.cpp @@ -1,11 +1,12 @@ #include "generator.hpp" -RandomNumberGenerator::RandomNumberGenerator(const uint32_t &seed) +RandomNumberGenerator::RandomNumberGenerator(const uint32_t &seed) noexcept { this->_generator = std::make_unique<std::mt19937>(seed); } -uint32_t RandomNumberGenerator::in_range(const uint32_t &a, const uint32_t &b) const +uint32_t RandomNumberGenerator::in_range(const uint32_t &a, + const uint32_t &b) const noexcept { auto random_distribution = std::uniform_int_distribution<uint32_t>(a, b); diff --git a/src/randomization/generator.hpp b/src/randomization/generator.hpp index 35bd9eb..4b002dd 100644 --- a/src/randomization/generator.hpp +++ b/src/randomization/generator.hpp @@ -8,9 +8,10 @@ class RandomNumberGenerator : public IRandomNumberGenerator { public: - explicit RandomNumberGenerator(const uint32_t &seed); + explicit RandomNumberGenerator(const uint32_t &seed) noexcept; - [[nodiscard]] uint32_t in_range(const uint32_t &a, const uint32_t &b) const override; + [[nodiscard]] uint32_t in_range(const uint32_t &a, + const uint32_t &b) const noexcept override; private: std::unique_ptr<std::mt19937> _generator; diff --git a/src/randomization/seed_generator.cpp b/src/randomization/seed_generator.cpp index 5d51e18..3afa275 100644 --- a/src/randomization/seed_generator.cpp +++ b/src/randomization/seed_generator.cpp @@ -1,11 +1,12 @@ #include "seed_generator.hpp" -SeedGenerator::SeedGenerator(const std::shared_ptr<std::random_device> &random_device) +SeedGenerator::SeedGenerator( + const std::shared_ptr<std::random_device> &random_device) noexcept : _random_device(random_device) { } -uint32_t SeedGenerator::random_seed() const +uint32_t SeedGenerator::random_seed() const noexcept { return (*_random_device)(); } diff --git a/src/randomization/seed_generator.hpp b/src/randomization/seed_generator.hpp index 1447a8c..087ad6b 100644 --- a/src/randomization/seed_generator.hpp +++ b/src/randomization/seed_generator.hpp @@ -8,9 +8,10 @@ class SeedGenerator : public ISeedGenerator { public: - explicit SeedGenerator(const std::shared_ptr<std::random_device> &random_device); + explicit SeedGenerator( + const std::shared_ptr<std::random_device> &random_device) noexcept; - [[nodiscard]] uint32_t random_seed() const override; + [[nodiscard]] uint32_t random_seed() const noexcept override; private: const std::shared_ptr<std::random_device> &_random_device; |