From 0dfb4e52abb3df5042e4c70c0579aef04c8b2010 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Sun, 11 Jun 2023 21:33:29 -0600 Subject: [PATCH] entdata.cc: avoid exception-throwing std::stod/stoi mostly because it's annoying when debugging with "break on first exception thrown" --- common/entdata.cc | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/common/entdata.cc b/common/entdata.cc index f88ebf48..55d6751a 100644 --- a/common/entdata.cc +++ b/common/entdata.cc @@ -20,6 +20,7 @@ #include #include +#include // atoi() #include #include @@ -50,32 +51,24 @@ const std::string &entdict_t::get(const std::string_view &key) const vec_t entdict_t::get_float(const std::string_view &key) const { - auto s = get(key); + const std::string &s = get(key); if (s.empty()) { return 0; } - try { - return std::stod(s); - } catch (std::exception &) { - return 0.0; - } + return atof(s.data()); } int32_t entdict_t::get_int(const std::string_view &key) const { - auto s = get(key); + const std::string &s = get(key); if (s.empty()) { return 0; } - try { - return std::stoi(s); - } catch (std::exception &) { - return 0; - } + return atoi(s.data()); } int32_t entdict_t::get_vector(const std::string_view &key, qvec3d &vec) const