Zig 0.17.0-dev (Split by item) This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig standard library.
std › compress › zstd › Decompress › Frame › Zstandard › Decode › updateFseTable Private Function updateFseTable Doc Source Private Function std.compress.zstd.Decompress.Frame.Zstandard.Decode.updateFseTable
fn updateFseTable (
self : *Decode ,
in : *Reader ,
remaining : *Limit ,
comptime choice : WhichFse ,
mode : SequencesSection .Header .Mode ,
) !void Params File compress/zstd/Decompress.zig: 676
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718 fn updateFseTable (
self : *Decode ,
in : *Reader ,
remaining : *Limit ,
comptime choice : WhichFse ,
mode : SequencesSection .Header .Mode ,
) !void {
const field_name = @tagName (choice );
switch (mode ) {
.predefined => {
@field (self , field_name ).accuracy_log =
@field (zstd .default_accuracy_log , field_name );
@field (self , field_name ).table =
@field (Table , "predefined_" ++ field_name );
},
.rle => {
@field (self , field_name ).accuracy_log = 0 ;
remaining .* = remaining .subtract (1 ) orelse return error .EndOfStream ;
@field (self , field_name ).table = .{ .rle = try in .takeByte () };
},
.fse => {
const max_table_size = 2048 ;
const peek_len : usize = remaining .minInt (max_table_size );
if (in .buffer .len < peek_len ) return error .InputBufferUndersize ;
const limited_buffer = try in .peek (peek_len );
var bit_reader : BitReader = .{ .bytes = limited_buffer };
const table_size = try Table .decode (
&bit_reader ,
@field (zstd .table_symbol_count_max , field_name ),
@field (zstd .table_accuracy_log_max , field_name ),
&@field (self , field_name ++ "_fse_buffer" ),
);
@field (self , field_name ).table = .{
.fse = (&@field (self , field_name ++ "_fse_buffer" ))[0 ..table_size ],
};
@field (self , field_name ).accuracy_log = std .math .log2_int_ceil (usize , table_size );
in .toss (bit_reader .index );
remaining .* = remaining .subtract (bit_reader .index ).?;
},
.repeat => if (self .fse_tables_undefined ) return error .RepeatModeFirst ,
}
}
TODO: don't use
@field