@@ -456,7 +456,7 @@ fn diffHalfMatchInternal(
456456 const prefix_length = diffCommonPrefix (long_text [i .. ], short_text [@as (usize , @intCast (j )).. ]);
457457 const suffix_length = diffCommonSuffix (long_text [0.. i ], short_text [0.. @as (usize , @intCast (j ))]);
458458 if (best_common .items .len < suffix_length + prefix_length ) {
459- best_common .items . len = 0 ;
459+ best_common .clearRetainingCapacity () ;
460460 const a = short_text [@as (usize , @intCast (j - @as (isize , @intCast (suffix_length )))) .. @as (usize , @intCast (j - @as (isize , @intCast (suffix_length )))) + suffix_length ];
461461 try best_common .appendSlice (allocator , a );
462462 const b = short_text [@as (usize , @intCast (j )) .. @as (usize , @intCast (j )) + prefix_length ];
@@ -760,8 +760,8 @@ fn diffLineMode(
760760 }
761761 count_insert = 0 ;
762762 count_delete = 0 ;
763- text_delete .items . len = 0 ;
764- text_insert .items . len = 0 ;
763+ text_delete .clearRetainingCapacity () ;
764+ text_insert .clearRetainingCapacity () ;
765765 },
766766 }
767767 pointer += 1 ;
@@ -995,8 +995,8 @@ fn diffCleanupMerge(allocator: std.mem.Allocator, diffs: *DiffList) DiffError!vo
995995 }
996996 count_insert = 0 ;
997997 count_delete = 0 ;
998- text_delete .items . len = 0 ;
999- text_insert .items . len = 0 ;
998+ text_delete .clearRetainingCapacity () ;
999+ text_insert .clearRetainingCapacity () ;
10001000 },
10011001 }
10021002 }
@@ -1274,13 +1274,13 @@ pub fn diffCleanupSemanticLossless(
12741274 if (score >= best_score ) {
12751275 best_score = score ;
12761276
1277- best_equality_1 .items . len = 0 ;
1277+ best_equality_1 .clearRetainingCapacity () ;
12781278 try best_equality_1 .appendSlice (allocator , equality_1 .items );
12791279
1280- best_edit .items . len = 0 ;
1280+ best_edit .clearRetainingCapacity () ;
12811281 try best_edit .appendSlice (allocator , edit .items );
12821282
1283- best_equality_2 .items . len = 0 ;
1283+ best_equality_2 .clearRetainingCapacity () ;
12841284 try best_equality_2 .appendSlice (allocator , equality_2 .items );
12851285 }
12861286 }
@@ -1401,7 +1401,7 @@ pub fn diffCleanupEfficiency(
14011401 last_equality = diffs .items [pointer ].text ;
14021402 } else {
14031403 // Not a candidate, and can never become one.
1404- equalities .items . len = 0 ;
1404+ equalities .clearRetainingCapacity () ;
14051405 last_equality = "" ;
14061406 }
14071407 post_ins = false ;
@@ -1440,7 +1440,7 @@ pub fn diffCleanupEfficiency(
14401440 // No changes made which could affect previous entry, keep going.
14411441 post_ins = true ;
14421442 post_del = true ;
1443- equalities .items . len = 0 ;
1443+ equalities .clearRetainingCapacity () ;
14441444 } else {
14451445 if (equalities .items .len > 0 ) {
14461446 _ = equalities .pop ();
@@ -1708,7 +1708,7 @@ test diffLinesToChars {
17081708 try testing .expectEqualStrings ("\u{0002}\u{0001}\u{0002} " , result .chars_2 ); // Shared lines #2
17091709 try testing .expectEqualDeep (tmp_array_list .items , result .line_array .items ); // Shared lines #3
17101710
1711- tmp_array_list .items . len = 0 ;
1711+ tmp_array_list .clearRetainingCapacity () ;
17121712 try tmp_array_list .append (allocator , "" );
17131713 try tmp_array_list .append (allocator , "alpha\r \n " );
17141714 try tmp_array_list .append (allocator , "beta\r \n " );
@@ -1720,7 +1720,7 @@ test diffLinesToChars {
17201720 try testing .expectEqualStrings ("\u{0001}\u{0002}\u{0003}\u{0003} " , result .chars_2 ); // Empty string and blank lines #2
17211721 try testing .expectEqualDeep (tmp_array_list .items , result .line_array .items ); // Empty string and blank lines #3
17221722
1723- tmp_array_list .items . len = 0 ;
1723+ tmp_array_list .clearRetainingCapacity () ;
17241724 try tmp_array_list .append (allocator , "" );
17251725 try tmp_array_list .append (allocator , "a" );
17261726 try tmp_array_list .append (allocator , "b" );
@@ -1742,7 +1742,7 @@ test diffLinesToChars {
17421742 // take care of the problem, but I don't like it.
17431743
17441744 const n : u8 = 255 ;
1745- tmp_array_list .items . len = 0 ;
1745+ tmp_array_list .clearRetainingCapacity () ;
17461746
17471747 var line_list : std .ArrayListUnmanaged (u8 ) = .empty ;
17481748 defer line_list .deinit (allocator );
0 commit comments