From 2ab86a4895e6bb219ee160be03e2b12c67a63b43 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Mon, 12 Dec 2016 15:56:42 +0100 Subject: ConfigOptionVector::get_at(idx) Avoid using exceptons for normal work flow. Assert if the vector is empty. --- xs/src/libslic3r/Config.hpp | 8 +++----- 1 file 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 #include #include #include @@ -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(); }; }; -- cgit v1.2.3