user packing

This commit is contained in:
2022-02-19 11:35:29 +02:00
committed by Motiejus Jakštys
parent 93c6a1c12a
commit 13b75e8046
3 changed files with 118 additions and 50 deletions

View File

@@ -41,7 +41,7 @@ pub const ShellWriter = struct {
const ShellSections = struct {
index: BoundedArray(ShellIndex, MaxShells),
blob: BoundedArray(u8, MaxShells * MaxShellLen),
indices: StringHashMap(u10),
indices: StringHashMap(u6),
// initializes and populates shell sections. All strings are copied,
// nothing is owned.
@@ -52,10 +52,10 @@ pub const ShellWriter = struct {
var self = ShellSections{
.index = try BoundedArray(ShellIndex, MaxShells).init(shells.len),
.blob = try BoundedArray(u8, MaxShells * MaxShellLen).init(0),
.indices = StringHashMap(u10).init(allocator),
.indices = StringHashMap(u6).init(allocator),
};
var fullOffset: u12 = 0;
var idx: u10 = 0;
var idx: u6 = 0;
while (idx < shells.len) {
const len = @intCast(u6, shells.get(idx).len);
try self.blob.appendSlice(shells.get(idx));
@@ -90,7 +90,7 @@ pub const ShellWriter = struct {
self.* = undefined;
}
pub fn getIndex(self: *const ShellSections, shell: []const u8) ?u10 {
pub fn getIndex(self: *const ShellSections, shell: []const u8) ?u6 {
return self.indices.get(shell);
}
};