Skip to content

Commit

Permalink
Change order of incrementation
Browse files Browse the repository at this point in the history
  • Loading branch information
timacpp committed Oct 14, 2021
1 parent 2b1db18 commit b988754
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,16 @@ namespace {

std::pair<std::string, std::string> 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};
Expand Down

0 comments on commit b988754

Please sign in to comment.