@@ -95,7 +95,7 @@ pub const Node = struct {
95
95
// To: A -> C -> B
96
96
const mid = try allocator .create (Node );
97
97
mid .* = .{ .base = self .base };
98
- var to_label = try allocator .dupe (u8 , edge .label [match .. ]);
98
+ const to_label = try allocator .dupe (u8 , edge .label [match .. ]);
99
99
allocator .free (edge .label );
100
100
const to_node = edge .to ;
101
101
edge .to = mid ;
@@ -242,7 +242,7 @@ pub const Node = struct {
242
242
/// Updates offset of this node in the output byte stream.
243
243
fn finalize (self : * Node , offset_in_trie : u64 ) ! FinalizeResult {
244
244
var stream = std .io .countingWriter (std .io .null_writer );
245
- var writer = stream .writer ();
245
+ const writer = stream .writer ();
246
246
247
247
var node_size : u64 = 0 ;
248
248
if (self .terminal_info ) | info | {
@@ -392,7 +392,7 @@ pub fn deinit(self: *Trie, allocator: Allocator) void {
392
392
}
393
393
394
394
test "Trie node count" {
395
- var gpa = testing .allocator ;
395
+ const gpa = testing .allocator ;
396
396
var trie : Trie = .{};
397
397
defer trie .deinit (gpa );
398
398
try trie .init (gpa );
@@ -438,7 +438,7 @@ test "Trie node count" {
438
438
}
439
439
440
440
test "Trie basic" {
441
- var gpa = testing .allocator ;
441
+ const gpa = testing .allocator ;
442
442
var trie : Trie = .{};
443
443
defer trie .deinit (gpa );
444
444
try trie .init (gpa );
@@ -496,7 +496,7 @@ fn expectEqualHexStrings(expected: []const u8, given: []const u8) !void {
496
496
const given_fmt = try std .fmt .allocPrint (testing .allocator , "{x}" , .{std .fmt .fmtSliceHexLower (given )});
497
497
defer testing .allocator .free (given_fmt );
498
498
const idx = mem .indexOfDiff (u8 , expected_fmt , given_fmt ).? ;
499
- var padding = try testing .allocator .alloc (u8 , idx + 5 );
499
+ const padding = try testing .allocator .alloc (u8 , idx + 5 );
500
500
defer testing .allocator .free (padding );
501
501
@memset (padding , ' ' );
502
502
std .debug .print ("\n EXP: {s}\n GIV: {s}\n {s}^ -- first differing byte\n " , .{ expected_fmt , given_fmt , padding });
@@ -534,7 +534,7 @@ test "write Trie to a byte stream" {
534
534
0x3 , 0x0 , 0x80 , 0x20 , 0x0 , // terminal node
535
535
};
536
536
537
- var buffer = try gpa .alloc (u8 , trie .size );
537
+ const buffer = try gpa .alloc (u8 , trie .size );
538
538
defer gpa .free (buffer );
539
539
var stream = std .io .fixedBufferStream (buffer );
540
540
{
@@ -550,7 +550,7 @@ test "write Trie to a byte stream" {
550
550
}
551
551
552
552
test "parse Trie from byte stream" {
553
- var gpa = testing .allocator ;
553
+ const gpa = testing .allocator ;
554
554
555
555
const in_buffer = [_ ]u8 {
556
556
0x0 , 0x1 , // node root
@@ -573,15 +573,15 @@ test "parse Trie from byte stream" {
573
573
574
574
try trie .finalize (gpa );
575
575
576
- var out_buffer = try gpa .alloc (u8 , trie .size );
576
+ const out_buffer = try gpa .alloc (u8 , trie .size );
577
577
defer gpa .free (out_buffer );
578
578
var out_stream = std .io .fixedBufferStream (out_buffer );
579
579
_ = try trie .write (out_stream .writer ());
580
580
try expectEqualHexStrings (& in_buffer , out_buffer );
581
581
}
582
582
583
583
test "ordering bug" {
584
- var gpa = testing .allocator ;
584
+ const gpa = testing .allocator ;
585
585
var trie : Trie = .{};
586
586
defer trie .deinit (gpa );
587
587
try trie .init (gpa );
@@ -605,7 +605,7 @@ test "ordering bug" {
605
605
0x00 , 0x12 , 0x03 , 0x00 , 0xD8 , 0x0A , 0x00 ,
606
606
};
607
607
608
- var buffer = try gpa .alloc (u8 , trie .size );
608
+ const buffer = try gpa .alloc (u8 , trie .size );
609
609
defer gpa .free (buffer );
610
610
var stream = std .io .fixedBufferStream (buffer );
611
611
// Writing finalized trie again should yield the same result.
0 commit comments