diff options
author | bubnikv <bubnikv@gmail.com> | 2016-12-12 17:56:42 +0300 |
---|---|---|
committer | bubnikv <bubnikv@gmail.com> | 2016-12-12 17:56:42 +0300 |
commit | 2ab86a4895e6bb219ee160be03e2b12c67a63b43 (patch) | |
tree | 7cfae3a74e462e36a9fc8c502ad9d5a1f4699596 | |
parent | d775c6c14c2ab2c746ef40cacc27ae4c707ef0b4 (diff) |
ConfigOptionVector::get_at(idx)
Avoid using exceptons for normal work flow. Assert if the vector is empty.
-rw-r--r-- | xs/src/libslic3r/Config.hpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/xs/src/libslic3r/Config.hpp b/xs/src/libslic3r/Config.hpp index 3fbd82060..6c8fa9f27 100644 --- a/xs/src/libslic3r/Config.hpp +++ b/xs/src/libslic3r/Config.hpp @@ -1,6 +1,7 @@ #ifndef slic3r_Config_hpp_ #define slic3r_Config_hpp_ +#include <assert.h> #include <map> #include <climits> #include <cstdio> @@ -73,11 +74,8 @@ class ConfigOptionVector : public ConfigOptionVectorBase }; T get_at(size_t i) const { - try { - return this->values.at(i); - } catch (const std::out_of_range& oor) { - return this->values.front(); - } + assert(! this->values.empty()); + return (i < this->values.size()) ? this->values[i] : this->values.front(); }; }; |