Skip to content

Commit 8a67dfb

Browse files
committed
2 parents 14a6d1a + 4222121 commit 8a67dfb

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

include/semver/semver.hpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,15 @@ namespace semver
141141

142142
prerelease_descriptor increment() const {
143143
std::vector<prerelease_part> new_parts = (m_parts);
144-
int last_numeric_index = -1;
144+
size_t last_numeric_index = 0;
145+
bool last_numeric_index_found = false;
145146
for (size_t i = 0; i < new_parts.size(); ++i) {
146-
if (new_parts[i].numeric()) last_numeric_index = i;
147+
if (new_parts[i].numeric()){
148+
last_numeric_index = i;
149+
last_numeric_index_found = true;
150+
}
147151
}
148-
if (last_numeric_index != -1) {
152+
if (last_numeric_index_found) {
149153
prerelease_part last = new_parts[last_numeric_index];
150154
new_parts[last_numeric_index] = prerelease_part(std::to_string(last.numeric_value() + 1));
151155
} else {

0 commit comments

Comments
 (0)