std.compress.xz: eliminate dependency on std.Io.bitReader

This commit is contained in:
Andrew Kelley 2025-07-27 16:38:43 -07:00
parent 89cd42ee80
commit bb29846732

View File

@ -12,17 +12,11 @@ pub const Check = enum(u4) {
}; };
fn readStreamFlags(reader: anytype, check: *Check) !void { fn readStreamFlags(reader: anytype, check: *Check) !void {
var bit_reader = std.io.bitReader(.little, reader); const reserved1 = try reader.readByte();
if (reserved1 != 0) return error.CorruptInput;
const reserved1 = try bit_reader.readBitsNoEof(u8, 8); const byte = try reader.readByte();
if (reserved1 != 0) if ((byte >> 4) != 0) return error.CorruptInput;
return error.CorruptInput; check.* = @enumFromInt(@as(u4, @truncate(byte)));
check.* = @as(Check, @enumFromInt(try bit_reader.readBitsNoEof(u4, 4)));
const reserved2 = try bit_reader.readBitsNoEof(u4, 4);
if (reserved2 != 0)
return error.CorruptInput;
} }
pub fn decompress(allocator: Allocator, reader: anytype) !Decompress(@TypeOf(reader)) { pub fn decompress(allocator: Allocator, reader: anytype) !Decompress(@TypeOf(reader)) {