From d0a9ef93a37344d2c559a37a8a0d096415a58231 Mon Sep 17 00:00:00 2001 From: Joel Rosdahl Date: Wed, 4 Aug 2021 21:42:08 +0200 Subject: [PATCH] refactor: Use util::parse_double --- src/Config.cpp | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/src/Config.cpp b/src/Config.cpp index f135b8b6f..723588085 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -228,22 +228,6 @@ format_bool(bool value) return value ? "true" : "false"; } -double -parse_double(const std::string& value) -{ - size_t end; - double result; - try { - result = std::stod(value, &end); - } catch (std::exception& e) { - throw core::Error(e.what()); - } - if (end != value.size()) { - throw core::Error("invalid floating point: \"{}\"", value); - } - return result; -} - std::string format_cache_size(uint64_t value) { @@ -924,7 +908,8 @@ Config::set_item(const std::string& key, break; case ConfigItem::limit_multiple: - m_limit_multiple = Util::clamp(parse_double(value), 0.0, 1.0); + m_limit_multiple = Util::clamp( + util::value_or_throw(util::parse_double(value)), 0.0, 1.0); break; case ConfigItem::log_file: -- 2.47.2