@@ -112,7 +112,7 @@ fn diffInternal(
112
112
113
113
// Trim off common suffix (speedup).
114
114
common_length = diffCommonSuffix (trimmed_before , trimmed_after );
115
- var common_suffix = trimmed_before [trimmed_before .len - common_length .. ];
115
+ const common_suffix = trimmed_before [trimmed_before .len - common_length .. ];
116
116
trimmed_before = trimmed_before [0 .. trimmed_before .len - common_length ];
117
117
trimmed_after = trimmed_after [0 .. trimmed_after .len - common_length ];
118
118
@@ -216,7 +216,7 @@ fn diffCompute(
216
216
// A half-match was found, sort out the return data.
217
217
218
218
// Send both pairs off for separate processing.
219
- var diffs_a = try dmp .diffInternal (
219
+ const diffs_a = try dmp .diffInternal (
220
220
allocator ,
221
221
half_match .prefix_before ,
222
222
half_match .prefix_after ,
@@ -283,9 +283,9 @@ fn diffHalfMatch(
283
283
}
284
284
285
285
// First check if the second quarter is the seed for a half-match.
286
- var half_match_1 = try dmp .diffHalfMatchInternal (allocator , long_text , short_text , (long_text .len + 3 ) / 4 );
286
+ const half_match_1 = try dmp .diffHalfMatchInternal (allocator , long_text , short_text , (long_text .len + 3 ) / 4 );
287
287
// Check again based on the third quarter.
288
- var half_match_2 = try dmp .diffHalfMatchInternal (allocator , long_text , short_text , (long_text .len + 1 ) / 2 );
288
+ const half_match_2 = try dmp .diffHalfMatchInternal (allocator , long_text , short_text , (long_text .len + 1 ) / 2 );
289
289
290
290
var half_match : ? HalfMatchResult = null ;
291
291
if (half_match_1 == null and half_match_2 == null ) {
@@ -346,8 +346,8 @@ fn diffHalfMatchInternal(
346
346
j = @as (isize , @intCast (std .mem .indexOf (u8 , short_text [@as (usize , @intCast (j + 1 )).. ], seed ) orelse break :b false )) + j + 1 ;
347
347
break :b true ;
348
348
}) {
349
- var prefix_length = diffCommonPrefix (long_text [i .. ], short_text [@as (usize , @intCast (j )).. ]);
350
- var suffix_length = diffCommonSuffix (long_text [0.. i ], short_text [0.. @as (usize , @intCast (j ))]);
349
+ const prefix_length = diffCommonPrefix (long_text [i .. ], short_text [@as (usize , @intCast (j )).. ]);
350
+ const suffix_length = diffCommonSuffix (long_text [0.. i ], short_text [0.. @as (usize , @intCast (j ))]);
351
351
if (best_common .items .len < suffix_length + prefix_length ) {
352
352
best_common .items .len = 0 ;
353
353
try best_common .appendSlice (allocator , short_text [@as (usize , @intCast (j - @as (isize , @intCast (suffix_length )))) .. @as (usize , @intCast (j - @as (isize , @intCast (suffix_length )))) + suffix_length ]);
@@ -425,7 +425,7 @@ fn diffBisect(
425
425
// Walk the front path one step.
426
426
var k1 = - d + k1start ;
427
427
while (k1 <= d - k1end ) : (k1 += 2 ) {
428
- var k1_offset = v_offset + k1 ;
428
+ const k1_offset = v_offset + k1 ;
429
429
var x1 : isize = 0 ;
430
430
if (k1 == - d or (k1 != d and
431
431
v1 .items [@intCast (k1_offset - 1 )] < v1 .items [@intCast (k1_offset + 1 )]))
@@ -449,7 +449,7 @@ fn diffBisect(
449
449
// Ran off the bottom of the graph.
450
450
k1start += 2 ;
451
451
} else if (front ) {
452
- var k2_offset = v_offset + delta - k1 ;
452
+ const k2_offset = v_offset + delta - k1 ;
453
453
if (k2_offset >= 0 and k2_offset < v_length and v2 .items [@intCast (k2_offset )] != -1 ) {
454
454
// Mirror x2 onto top-left coordinate system.
455
455
const x2 = before_length - v2 .items [@intCast (k2_offset )];
@@ -557,10 +557,10 @@ fn diffLineMode(
557
557
deadline : u64 ,
558
558
) DiffError ! DiffList {
559
559
// Scan the text on a line-by-line basis first.
560
- var a = try diffLinesToChars (allocator , text1_in , text2_in );
561
- var text1 = a .chars_1 ;
562
- var text2 = a .chars_2 ;
563
- var line_array = a .line_array ;
560
+ const a = try diffLinesToChars (allocator , text1_in , text2_in );
561
+ const text1 = a .chars_1 ;
562
+ const text2 = a .chars_2 ;
563
+ const line_array = a .line_array ;
564
564
565
565
var diffs : DiffList = try dmp .diffInternal (allocator , text1 , text2 , false , deadline );
566
566
@@ -607,7 +607,7 @@ fn diffLineMode(
607
607
&.{},
608
608
);
609
609
pointer = pointer - count_delete - count_insert ;
610
- var sub_diff = try dmp .diffInternal (allocator , text_delete .items , text_insert .items , false , deadline );
610
+ const sub_diff = try dmp .diffInternal (allocator , text_delete .items , text_insert .items , false , deadline );
611
611
// diffs.InsertRange(pointer, sub_diff);
612
612
try diffs .insertSlice (allocator , pointer , sub_diff .items );
613
613
pointer = pointer + sub_diff .items .len ;
@@ -654,8 +654,8 @@ fn diffLinesToChars(
654
654
try line_array .append (allocator , "" );
655
655
656
656
// Allocate 2/3rds of the space for text1, the rest for text2.
657
- var chars1 = try diffLinesToCharsMunge (allocator , text1 , & line_array , & line_hash , 170 );
658
- var chars2 = try diffLinesToCharsMunge (allocator , text2 , & line_array , & line_hash , 255 );
657
+ const chars1 = try diffLinesToCharsMunge (allocator , text1 , & line_array , & line_hash , 170 );
658
+ const chars2 = try diffLinesToCharsMunge (allocator , text2 , & line_array , & line_hash , 255 );
659
659
return .{ .chars_1 = chars1 , .chars_2 = chars2 , .line_array = line_array };
660
660
}
661
661
@@ -997,8 +997,8 @@ fn diffCleanupSemantic(allocator: std.mem.Allocator, diffs: *DiffList) DiffError
997
997
{
998
998
const deletion = diffs .items [@intCast (pointer - 1 )].text ;
999
999
const insertion = diffs .items [@intCast (pointer )].text ;
1000
- var overlap_length1 : usize = diffCommonOverlap (deletion , insertion );
1001
- var overlap_length2 : usize = diffCommonOverlap (insertion , deletion );
1000
+ const overlap_length1 : usize = diffCommonOverlap (deletion , insertion );
1001
+ const overlap_length2 : usize = diffCommonOverlap (insertion , deletion );
1002
1002
if (overlap_length1 >= overlap_length2 ) {
1003
1003
if (@as (f32 , @floatFromInt (overlap_length1 )) >= @as (f32 , @floatFromInt (deletion .len )) / 2.0 or
1004
1004
@as (f32 , @floatFromInt (overlap_length1 )) >= @as (f32 , @floatFromInt (insertion .len )) / 2.0 )
@@ -1314,8 +1314,8 @@ fn diffCommonOverlap(text1_in: []const u8, text2_in: []const u8) usize {
1314
1314
var text2 = text2_in ;
1315
1315
1316
1316
// Cache the text lengths to prevent multiple calls.
1317
- var text1_length = text1 .len ;
1318
- var text2_length = text2 .len ;
1317
+ const text1_length = text1 .len ;
1318
+ const text2_length = text2 .len ;
1319
1319
// Eliminate the null case.
1320
1320
if (text1_length == 0 or text2_length == 0 ) {
1321
1321
return 0 ;
0 commit comments