shr user and group offsets
by 3 bits, all of them.
This commit is contained in:
parent
249cdb1a31
commit
8a4bb62613
@ -3,6 +3,7 @@ const fmt = std.fmt;
|
|||||||
const mem = std.mem;
|
const mem = std.mem;
|
||||||
const math = std.math;
|
const math = std.math;
|
||||||
const sort = std.sort;
|
const sort = std.sort;
|
||||||
|
const assert = std.debug.assert;
|
||||||
const unicode = std.unicode;
|
const unicode = std.unicode;
|
||||||
const Allocator = std.mem.Allocator;
|
const Allocator = std.mem.Allocator;
|
||||||
const ArrayListUnmanaged = std.ArrayListUnmanaged;
|
const ArrayListUnmanaged = std.ArrayListUnmanaged;
|
||||||
@ -224,11 +225,11 @@ pub fn usersSection(
|
|||||||
errdefer blob.deinit();
|
errdefer blob.deinit();
|
||||||
var i: usize = 0;
|
var i: usize = 0;
|
||||||
while (i < corpus.users.len) : (i += 1) {
|
while (i < corpus.users.len) : (i += 1) {
|
||||||
// TODO: this is inefficient; it's calling `.slice()` on every iteration
|
// TODO: this is inefficient by calling `.slice()` on every iteration
|
||||||
const user = corpus.users.get(i);
|
const user = corpus.users.get(i);
|
||||||
const user_offset = try math.cast(u32, blob.items.len);
|
const user_offset = try math.cast(u35, blob.items.len);
|
||||||
std.debug.assert(user_offset & 7 == 0);
|
assert(user_offset & 7 == 0);
|
||||||
idx2offset[i] = user_offset;
|
idx2offset[i] = @truncate(u32, user_offset >> 3);
|
||||||
try userImport.PackedUser.packTo(
|
try userImport.PackedUser.packTo(
|
||||||
&blob,
|
&blob,
|
||||||
user,
|
user,
|
||||||
@ -324,7 +325,7 @@ pub fn groupsSection(
|
|||||||
// TODO: this is inefficient; it's calling `.slice()` on every iteration
|
// TODO: this is inefficient; it's calling `.slice()` on every iteration
|
||||||
const group = corpus.groups.get(i);
|
const group = corpus.groups.get(i);
|
||||||
const group_offset = try math.cast(u32, blob.items.len);
|
const group_offset = try math.cast(u32, blob.items.len);
|
||||||
std.debug.assert(group_offset & 7 == 0);
|
assert(group_offset & 7 == 0);
|
||||||
idx2offset[i] = group_offset;
|
idx2offset[i] = group_offset;
|
||||||
const group_stored = groupImport.GroupStored{
|
const group_stored = groupImport.GroupStored{
|
||||||
.gid = group.gid,
|
.gid = group.gid,
|
||||||
@ -355,7 +356,7 @@ pub fn bdzIdx(
|
|||||||
else => unreachable,
|
else => unreachable,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
std.debug.assert(keys.len <= math.maxInt(u32));
|
assert(keys.len <= math.maxInt(u32));
|
||||||
var result = try allocator.alloc(u32, keys.len);
|
var result = try allocator.alloc(u32, keys.len);
|
||||||
for (keys) |key, i| {
|
for (keys) |key, i| {
|
||||||
const hash = search_fn(packed_mphf, key);
|
const hash = search_fn(packed_mphf, key);
|
||||||
|
@ -79,6 +79,7 @@ pub const ShellWriter = struct {
|
|||||||
try self.blob.appendSlice(shells.get(idx));
|
try self.blob.appendSlice(shells.get(idx));
|
||||||
const our_shell = self.blob.constSlice()[full_offset .. full_offset + len];
|
const our_shell = self.blob.constSlice()[full_offset .. full_offset + len];
|
||||||
try self.indices.put(our_shell, idx);
|
try self.indices.put(our_shell, idx);
|
||||||
|
std.debug.assert(full_offset & 3 == 0);
|
||||||
self.index.set(idx, ShellIndex{
|
self.index.set(idx, ShellIndex{
|
||||||
.offset = try std.math.cast(u10, full_offset >> 2),
|
.offset = try std.math.cast(u10, full_offset >> 2),
|
||||||
.len = len - 1,
|
.len = len - 1,
|
||||||
|
Loading…
Reference in New Issue
Block a user