Explorar el Código

LibDiff: Replace DeprecatedString with StringView in parse_hunk_location

Shannon Booth hace 2 años
padre
commit
dbd838efdf
Se han modificado 2 ficheros con 7 adiciones y 7 borrados
  1. 6 6
      Userland/Libraries/LibDiff/Hunks.cpp
  2. 1 1
      Userland/Libraries/LibDiff/Hunks.h

+ 6 - 6
Userland/Libraries/LibDiff/Hunks.cpp

@@ -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 };
 }
 

+ 1 - 1
Userland/Libraries/LibDiff/Hunks.h

@@ -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);
 };