From dbd838efdf8d2e2d9db66295ac1d1326251baab0 Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Sat, 24 Jun 2023 12:40:15 +1200 Subject: [PATCH] LibDiff: Replace DeprecatedString with StringView in parse_hunk_location --- Userland/Libraries/LibDiff/Hunks.cpp | 12 ++++++------ Userland/Libraries/LibDiff/Hunks.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Userland/Libraries/LibDiff/Hunks.cpp b/Userland/Libraries/LibDiff/Hunks.cpp index e7f2d6290e..1482103841 100644 --- a/Userland/Libraries/LibDiff/Hunks.cpp +++ b/Userland/Libraries/LibDiff/Hunks.cpp @@ -74,17 +74,17 @@ Vector 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 }; } diff --git a/Userland/Libraries/LibDiff/Hunks.h b/Userland/Libraries/LibDiff/Hunks.h index 0c8f42be8b..dd140feb8e 100644 --- a/Userland/Libraries/LibDiff/Hunks.h +++ b/Userland/Libraries/LibDiff/Hunks.h @@ -33,5 +33,5 @@ struct Hunk { }; Vector parse_hunks(DeprecatedString const& diff); -HunkLocation parse_hunk_location(DeprecatedString const& location_line); +HunkLocation parse_hunk_location(StringView location_line); };