std::string orig_line(line.data(), line.length());
std::string abs_inc_path =
util::replace_first(orig_line, ctx.config.msvc_dep_prefix(), "");
- abs_inc_path = util::strip_whitespace(abs_inc_path);
- fs::path rel_inc_path = core::make_relative_path(ctx, abs_inc_path);
+ std::string_view stripped_abs_inc_path =
+ util::strip_whitespace(abs_inc_path);
+ fs::path rel_inc_path =
+ core::make_relative_path(ctx, stripped_abs_inc_path);
std::string line_with_rel_inc = util::replace_first(
- orig_line, abs_inc_path, util::pstr(rel_inc_path).str());
+ orig_line, stripped_abs_inc_path, util::pstr(rel_inc_path).str());
new_stdout_data.insert(new_stdout_data.end(),
line_with_rel_inc.data(),
line_with_rel_inc.size());
std::string* value,
std::string* error_message)
{
- std::string stripped_line = util::strip_whitespace(line);
+ std::string_view stripped_line = util::strip_whitespace(line);
if (stripped_line.empty() || stripped_line[0] == '#') {
return true;
}
-// Copyright (C) 2025 Joel Rosdahl and other contributors
+// Copyright (C) 2025-2026 Joel Rosdahl and other contributors
//
// See doc/authors.adoc for a complete list of contributors.
//
bool
is_comment_or_blank(std::string_view line)
{
- std::string stripped = util::strip_whitespace(line);
+ std::string_view stripped = util::strip_whitespace(line);
return stripped.empty() || stripped[0] == '#';
}
split_into_views(raw_value, "\n", Tokenizer::Mode::include_empty);
for (auto line : value_lines) {
- std::string stripped = util::strip_whitespace(line);
+ std::string_view stripped = util::strip_whitespace(line);
if (!stripped.empty() && stripped[0] != '#') {
if (!normalized_value.empty()) {
normalized_value += ' ';
const std::optional<int64_t> max_value,
const std::string_view description)
{
- const std::string stripped_value = strip_whitespace(value);
+ const std::string stripped_value{strip_whitespace(value)};
size_t end = 0;
long long result = 0;
const std::string_view description,
const int base)
{
- const std::string stripped_value = strip_whitespace(value);
+ const std::string stripped_value{strip_whitespace(value)};
size_t end = 0;
unsigned long long result = 0;
return paths;
}
-std::string
+std::string_view
strip_whitespace(const std::string_view string)
{
const auto start =
std::find_if_not(string.begin(), string.end(), util::is_space);
const auto end =
std::find_if_not(string.rbegin(), string.rend(), util::is_space).base();
- return start < end ? std::string(start, end) : std::string();
+ return start < end ? string.substr(start - string.begin(), end - start)
+ : std::string_view{};
}
std::string
std::vector<std::filesystem::path> split_path_list(std::string_view path_list);
// Strip whitespace from left and right side of a string.
-[[nodiscard]] std::string strip_whitespace(std::string_view string);
+[[nodiscard]] std::string_view strip_whitespace(std::string_view string);
// Return lowercase `ch`.
char to_lower(char ch);