LibDiff: Replace DeprecatedString with StringView in parse_hunk_location

This commit is contained in:
Shannon Booth 2023-06-24 12:40:15 +12:00 committed by Andreas Kling
parent 84e8ff34a2
commit dbd838efdf
Notes: sideshowbarker 2024-07-17 22:55:25 +09:00
2 changed files with 7 additions and 7 deletions

View file

@ -74,17 +74,17 @@ Vector<Hunk> parse_hunks(DeprecatedString const& diff)
return hunks;
}
HunkLocation parse_hunk_location(DeprecatedString const& location_line)
HunkLocation parse_hunk_location(StringView location_line)
{
size_t char_index = 0;
struct StartAndLength {
size_t start { 0 };
size_t length { 0 };
};
auto parse_start_and_length_pair = [](DeprecatedString const& raw) {
auto parse_start_and_length_pair = [](StringView raw) {
auto index_of_separator = raw.find(',').value();
auto start = raw.substring(0, index_of_separator).to_uint().value();
auto length = raw.substring(index_of_separator + 1, raw.length() - index_of_separator - 1).to_uint().value();
auto start = raw.substring_view(0, index_of_separator).to_uint().value();
auto length = raw.substring_view(index_of_separator + 1, raw.length() - index_of_separator - 1).to_uint().value();
if (start != 0)
start--;
@ -114,8 +114,8 @@ HunkLocation parse_hunk_location(DeprecatedString const& location_line)
size_t target_location_end_index = char_index - 2;
auto original_pair = parse_start_and_length_pair(location_line.substring(original_location_start_index, original_location_end_index - original_location_start_index + 1));
auto target_pair = parse_start_and_length_pair(location_line.substring(target_location_start_index, target_location_end_index - target_location_start_index + 1));
auto original_pair = parse_start_and_length_pair(location_line.substring_view(original_location_start_index, original_location_end_index - original_location_start_index + 1));
auto target_pair = parse_start_and_length_pair(location_line.substring_view(target_location_start_index, target_location_end_index - target_location_start_index + 1));
return { original_pair.start, original_pair.length, target_pair.start, target_pair.length };
}

View file

@ -33,5 +33,5 @@ struct Hunk {
};
Vector<Hunk> parse_hunks(DeprecatedString const& diff);
HunkLocation parse_hunk_location(DeprecatedString const& location_line);
HunkLocation parse_hunk_location(StringView location_line);
};