From 17bf0c36034049324b093fdb9441be39047b5202 Mon Sep 17 00:00:00 2001 From: eidheim Date: Thu, 14 May 2020 13:37:50 +0200 Subject: [PATCH] Slight improvement to Go to implementation --- src/ctags.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ctags.cc b/src/ctags.cc index 2b48cb1..3ef0dd9 100644 --- a/src/ctags.cc +++ b/src/ctags.cc @@ -182,20 +182,22 @@ Ctags::Location Ctags::get_location(const std::string &line_, bool add_markup) c ///Split up a type into its various significant parts std::vector Ctags::get_type_parts(const std::string &type) { std::vector parts; - size_t text_start = -1; + size_t text_start = std::string::npos; for(size_t c = 0; c < type.size(); ++c) { auto &chr = type[c]; if((chr >= '0' && chr <= '9') || (chr >= 'a' && chr <= 'z') || (chr >= 'A' && chr <= 'Z') || chr == '_' || chr == '~') { - if(text_start == static_cast(-1)) + if(text_start == std::string::npos) text_start = c; } else { - if(text_start != static_cast(-1)) { + if(text_start != std::string::npos) { parts.emplace_back(type.substr(text_start, c - text_start)); - text_start = -1; + text_start = std::string::npos; } if(chr == '*' || chr == '&') parts.emplace_back(std::string() + chr); + else if(chr == '{') + break; } } return parts;