From 27b973e6d314fb27eacc5184a4e803bd83f32de5 Mon Sep 17 00:00:00 2001 From: eidheim Date: Sat, 29 Jun 2019 08:36:01 +0200 Subject: [PATCH] Language protocol: simplified LanguageProtocol::Offset::Offset --- src/source_language_protocol.cc | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/source_language_protocol.cc b/src/source_language_protocol.cc index 153085c..5ede00a 100644 --- a/src/source_language_protocol.cc +++ b/src/source_language_protocol.cc @@ -24,16 +24,8 @@ LanguageProtocol::Offset::Offset(const boost::property_tree::ptree &pt) { } catch(...) { // Workaround for buggy rls - auto line = pt.get("line"); - auto character = pt.get("character"); - if(line > static_cast(std::numeric_limits::max())) - this->line = std::numeric_limits::max(); - else - this->line = line; - if(character > static_cast(std::numeric_limits::max())) - this->character = std::numeric_limits::max(); - else - this->character = character; + line = std::min(pt.get("line"), static_cast(std::numeric_limits::max())); + character = std::min(pt.get("character"), static_cast(std::numeric_limits::max())); } } LanguageProtocol::Range::Range(const boost::property_tree::ptree &pt) : start(pt.get_child("start")), end(pt.get_child("end")) {}