@@ -456,7 +456,7 @@ fn diffHalfMatchInternal(
456
456
const prefix_length = diffCommonPrefix (long_text [i .. ], short_text [@as (usize , @intCast (j )).. ]);
457
457
const suffix_length = diffCommonSuffix (long_text [0.. i ], short_text [0.. @as (usize , @intCast (j ))]);
458
458
if (best_common .items .len < suffix_length + prefix_length ) {
459
- best_common .items . len = 0 ;
459
+ best_common .clearRetainingCapacity () ;
460
460
const a = short_text [@as (usize , @intCast (j - @as (isize , @intCast (suffix_length )))) .. @as (usize , @intCast (j - @as (isize , @intCast (suffix_length )))) + suffix_length ];
461
461
try best_common .appendSlice (allocator , a );
462
462
const b = short_text [@as (usize , @intCast (j )) .. @as (usize , @intCast (j )) + prefix_length ];
@@ -760,8 +760,8 @@ fn diffLineMode(
760
760
}
761
761
count_insert = 0 ;
762
762
count_delete = 0 ;
763
- text_delete .items . len = 0 ;
764
- text_insert .items . len = 0 ;
763
+ text_delete .clearRetainingCapacity () ;
764
+ text_insert .clearRetainingCapacity () ;
765
765
},
766
766
}
767
767
pointer += 1 ;
@@ -995,8 +995,8 @@ fn diffCleanupMerge(allocator: std.mem.Allocator, diffs: *DiffList) DiffError!vo
995
995
}
996
996
count_insert = 0 ;
997
997
count_delete = 0 ;
998
- text_delete .items . len = 0 ;
999
- text_insert .items . len = 0 ;
998
+ text_delete .clearRetainingCapacity () ;
999
+ text_insert .clearRetainingCapacity () ;
1000
1000
},
1001
1001
}
1002
1002
}
@@ -1274,13 +1274,13 @@ pub fn diffCleanupSemanticLossless(
1274
1274
if (score >= best_score ) {
1275
1275
best_score = score ;
1276
1276
1277
- best_equality_1 .items . len = 0 ;
1277
+ best_equality_1 .clearRetainingCapacity () ;
1278
1278
try best_equality_1 .appendSlice (allocator , equality_1 .items );
1279
1279
1280
- best_edit .items . len = 0 ;
1280
+ best_edit .clearRetainingCapacity () ;
1281
1281
try best_edit .appendSlice (allocator , edit .items );
1282
1282
1283
- best_equality_2 .items . len = 0 ;
1283
+ best_equality_2 .clearRetainingCapacity () ;
1284
1284
try best_equality_2 .appendSlice (allocator , equality_2 .items );
1285
1285
}
1286
1286
}
@@ -1401,7 +1401,7 @@ pub fn diffCleanupEfficiency(
1401
1401
last_equality = diffs .items [pointer ].text ;
1402
1402
} else {
1403
1403
// Not a candidate, and can never become one.
1404
- equalities .items . len = 0 ;
1404
+ equalities .clearRetainingCapacity () ;
1405
1405
last_equality = "" ;
1406
1406
}
1407
1407
post_ins = false ;
@@ -1440,7 +1440,7 @@ pub fn diffCleanupEfficiency(
1440
1440
// No changes made which could affect previous entry, keep going.
1441
1441
post_ins = true ;
1442
1442
post_del = true ;
1443
- equalities .items . len = 0 ;
1443
+ equalities .clearRetainingCapacity () ;
1444
1444
} else {
1445
1445
if (equalities .items .len > 0 ) {
1446
1446
_ = equalities .pop ();
@@ -1708,7 +1708,7 @@ test diffLinesToChars {
1708
1708
try testing .expectEqualStrings ("\u{0002}\u{0001}\u{0002} " , result .chars_2 ); // Shared lines #2
1709
1709
try testing .expectEqualDeep (tmp_array_list .items , result .line_array .items ); // Shared lines #3
1710
1710
1711
- tmp_array_list .items . len = 0 ;
1711
+ tmp_array_list .clearRetainingCapacity () ;
1712
1712
try tmp_array_list .append (allocator , "" );
1713
1713
try tmp_array_list .append (allocator , "alpha\r \n " );
1714
1714
try tmp_array_list .append (allocator , "beta\r \n " );
@@ -1720,7 +1720,7 @@ test diffLinesToChars {
1720
1720
try testing .expectEqualStrings ("\u{0001}\u{0002}\u{0003}\u{0003} " , result .chars_2 ); // Empty string and blank lines #2
1721
1721
try testing .expectEqualDeep (tmp_array_list .items , result .line_array .items ); // Empty string and blank lines #3
1722
1722
1723
- tmp_array_list .items . len = 0 ;
1723
+ tmp_array_list .clearRetainingCapacity () ;
1724
1724
try tmp_array_list .append (allocator , "" );
1725
1725
try tmp_array_list .append (allocator , "a" );
1726
1726
try tmp_array_list .append (allocator , "b" );
@@ -1742,7 +1742,7 @@ test diffLinesToChars {
1742
1742
// take care of the problem, but I don't like it.
1743
1743
1744
1744
const n : u8 = 255 ;
1745
- tmp_array_list .items . len = 0 ;
1745
+ tmp_array_list .clearRetainingCapacity () ;
1746
1746
1747
1747
var line_list : std .ArrayListUnmanaged (u8 ) = .empty ;
1748
1748
defer line_list .deinit (allocator );
0 commit comments