From b98875417c7b0ad134ebdb5ad5688b9ecf23018a Mon Sep 17 00:00:00 2001 From: tima Date: Thu, 14 Oct 2021 23:13:13 +0200 Subject: [PATCH] Change order of incrementation --- main.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index 6139699..887d13f 100644 --- a/main.cpp +++ b/main.cpp @@ -163,11 +163,16 @@ namespace { std::pair split_by_name(const std::string &input) { size_t div_pos{0}; + size_t name_start{SIZE_MAX}; + + while (!isalpha(input[div_pos]) || isalpha(input[div_pos + 1])) { + if (isalpha(input[div_pos]) && name_start == SIZE_MAX) + name_start = div_pos; - while (!isalpha(input[div_pos]) || isalpha(input[div_pos + 1])) div_pos++; + } - auto name{input.substr(0, div_pos + 1)}; + auto name{input.substr(name_start, div_pos + 1 - name_start)}; auto signals{input.substr(div_pos + 1, input.size() - div_pos - 1)}; return {name, signals};