1
Fork 0

doc nitpicks

This commit is contained in:
Motiejus Jakštys 2023-06-06 18:51:18 +03:00
parent 617c256863
commit ef4062edb7
1 changed files with 3 additions and 7 deletions

View File

@ -249,9 +249,7 @@ pub fn fieldOffsets(lengths: DBNumbers) DBNumbers {
var result: DBNumbers = undefined; var result: DBNumbers = undefined;
result.header = 0; result.header = 0;
var offset = comptime nblocks_n(u64, @sizeOf(Header)); var offset = comptime nblocks_n(u64, @sizeOf(Header));
// skipping header (so index 1). This used to be an inline for with stage1, // skipping header (so starting with index 1)
// but that and a comptime assertion crashes the compiler as of
// 0.11.0-dev.1580+a5b34a61a
inline for (DB_fields[1..], meta.fields(DBNumbers)[1..]) |db_field, dbn_field| { inline for (DB_fields[1..], meta.fields(DBNumbers)[1..]) |db_field, dbn_field| {
assert(mem.eql(u8, db_field.name, dbn_field.name)); assert(mem.eql(u8, db_field.name, dbn_field.name));
@field(result, db_field.name) = offset; @field(result, db_field.name) = offset;
@ -280,9 +278,7 @@ pub fn fromBytes(buf: []align(8) const u8) InvalidHeader!DB {
} }
pub fn packCGroupNoMembers(group: *const PackedGroup, buf: []u8) error{BufferTooSmall}!CGroup { pub fn packCGroupNoMembers(group: *const PackedGroup, buf: []u8) error{BufferTooSmall}!CGroup {
// first word in buf will be a pointer to null. that probably can be // First word in buf will be a pointer to null.
// simplified by writing (0)**word_size to the buffer, but let's pretend
// type safety for a moment.
const name_start = @sizeOf(?[*:0]const u8); const name_start = @sizeOf(?[*:0]const u8);
if (name_start > buf.len) return error.BufferTooSmall; if (name_start > buf.len) return error.BufferTooSmall;
var member_ptrs = mem.bytesAsSlice(?[*:0]const u8, buf[0..name_start]); var member_ptrs = mem.bytesAsSlice(?[*:0]const u8, buf[0..name_start]);
@ -729,7 +725,7 @@ pub fn nblocks_n(comptime T: type, nbytes: usize) T {
u16 => u22, u16 => u22,
u32 => u38, u32 => u38,
u64 => u70, u64 => u70,
else => @compileError("got " ++ @typeName(T) ++ ", only u8, u32 and u64 are supported"), else => @compileError("unsupported type " ++ @typeName(T)),
}; };
const upper = @intCast(B, mem.alignForward(nbytes, section_length)); const upper = @intCast(B, mem.alignForward(nbytes, section_length));
assert(upper & (section_length - 1) == 0); assert(upper & (section_length - 1) == 0);