Skip to content

Commit 4957e05

Browse files
committed
resolved method problem
1 parent cca4024 commit 4957e05

1 file changed

Lines changed: 8 additions & 20 deletions

File tree

src/version_weaver.cpp

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -245,15 +245,14 @@ std::string computeTildeUpperBound(const std::string_view &version) {
245245
std::to_string(major) + "." + std::to_string(minor + 1) + ".0";
246246
return upper;
247247
}
248+
248249
constexpr inline void trim_whitespace(std::string_view *input) noexcept {
249-
constexpr std::string_view whitespace = " \t\n\r\f\v";
250-
size_t start = input->find_first_not_of(whitespace);
251-
if (start == std::string_view::npos) { // If all characters are spaces
252-
*input = {};
253-
return;
254-
}
255-
size_t end = input->find_last_not_of(whitespace);
256-
*input = input->substr(start, end - start + 1);
250+
while (!input->empty() && std::isspace(input->front())) {
251+
input->remove_prefix(1);
252+
}
253+
while (!input->empty() && std::isspace(input->back())) {
254+
input->remove_suffix(1);
255+
}
257256
}
258257

259258
std::optional<std::string> minimum(std::string_view range) {
@@ -370,9 +369,7 @@ std::optional<std::string> minimum(std::string_view range) {
370369
}
371370
}
372371

373-
if (validCandidates.empty()) return std::nullopt;
374-
return *std::min_element(validCandidates.begin(), validCandidates.end(),
375-
compareSemVer);
372+
return bestCandidate;
376373
}
377374

378375
std::expected<std::string, parse_error> inc(version input,
@@ -423,15 +420,6 @@ std::expected<std::string, parse_error> inc(version input,
423420
}
424421
}
425422

426-
constexpr inline void trim_whitespace(std::string_view *input) noexcept {
427-
while (!input->empty() && std::isspace(input->front())) {
428-
input->remove_prefix(1);
429-
}
430-
while (!input->empty() && std::isspace(input->back())) {
431-
input->remove_suffix(1);
432-
}
433-
}
434-
435423
constexpr inline bool contains_only_digits(std::string_view input) noexcept {
436424
// Optimization opportunity: Replace this with a hash table lookup.
437425
return input.find_first_not_of("0123456789") == std::string_view::npos;

0 commit comments

Comments
 (0)