fix type/function name casing
This commit is contained in:
parent
275920a111
commit
1a48bb41ea
10
src/DB.zig
10
src/DB.zig
@ -305,14 +305,14 @@ const GroupMembersIter = struct {
|
||||
it: compress.DeltaDecompressionIterator,
|
||||
};
|
||||
|
||||
pub fn groupMembersIter(vit: *compress.varintSliceIterator) GroupMembersIter {
|
||||
pub fn groupMembersIter(vit: *compress.VarintSliceIterator) GroupMembersIter {
|
||||
return GroupMembersIter{
|
||||
.it = compress.deltaDecompressionIterator(vit),
|
||||
};
|
||||
}
|
||||
|
||||
//pub fn groupMembersIter(members_slice: []const u8) GroupMembersIter {
|
||||
// var vit = compress.VarintSliceIteratorMust(members_slice);
|
||||
// var vit = compress.varintSliceIteratorMust(members_slice);
|
||||
// return GroupMembersIter{
|
||||
// .it = compress.deltaDecompressionIterator(&vit),
|
||||
// };
|
||||
@ -321,7 +321,7 @@ pub fn groupMembersIter(vit: *compress.varintSliceIterator) GroupMembersIter {
|
||||
// dumps PackedGroup to []u8 and returns a CGroup.
|
||||
pub fn packCGroup(self: *const DB, group: PackedGroup, buf: []u8) error{BufferTooSmall}!CGroup {
|
||||
const members_slice = self.groupmembers[group.members_offset..];
|
||||
var vit = compress.VarintSliceIteratorMust(members_slice);
|
||||
var vit = compress.varintSliceIteratorMust(members_slice);
|
||||
const num_members = vit.remaining;
|
||||
|
||||
const ptr_end = @sizeOf(?[*:0]const u8) * (num_members + 1);
|
||||
@ -689,7 +689,7 @@ fn groupsSection(
|
||||
}
|
||||
|
||||
pub fn userGids(self: *const DB, offset: u64) compress.DeltaDecompressionIterator {
|
||||
var vit = compress.VarintSliceIteratorMust(self.additional_gids[offset..]);
|
||||
var vit = compress.varintSliceIteratorMust(self.additional_gids[offset..]);
|
||||
return compress.deltaDecompressionIterator(&vit);
|
||||
}
|
||||
|
||||
@ -875,7 +875,7 @@ test "additionalGids" {
|
||||
try testing.expect(offset == 0);
|
||||
continue;
|
||||
}
|
||||
var vit = try compress.VarintSliceIterator(additional_gids.blob[offset..]);
|
||||
var vit = try compress.varintSliceIterator(additional_gids.blob[offset..]);
|
||||
var it = compress.deltaDecompressionIterator(&vit);
|
||||
try testing.expectEqual(it.remaining(), groups.len);
|
||||
var i: u64 = 0;
|
||||
|
@ -101,14 +101,14 @@ pub fn putUvarint(buf: []u8, x: u64) usize {
|
||||
return i + 1;
|
||||
}
|
||||
|
||||
// VarintSliceIterator iterates over varint-encoded slice.
|
||||
// varintSliceIterator iterates over varint-encoded slice.
|
||||
// The first element is the length of the slice, in decoded numbers.
|
||||
pub const varintSliceIterator = struct {
|
||||
pub const VarintSliceIterator = struct {
|
||||
remaining: usize,
|
||||
arr: []const u8,
|
||||
idx: usize,
|
||||
|
||||
pub fn next(self: *varintSliceIterator) error{Overflow}!?u64 {
|
||||
pub fn next(self: *VarintSliceIterator) error{Overflow}!?u64 {
|
||||
if (self.remaining == 0)
|
||||
return null;
|
||||
const value = try uvarint(self.arr[self.idx..]);
|
||||
@ -117,7 +117,7 @@ pub const varintSliceIterator = struct {
|
||||
return value.value;
|
||||
}
|
||||
|
||||
pub fn nextMust(self: *varintSliceIterator) ?u64 {
|
||||
pub fn nextMust(self: *VarintSliceIterator) ?u64 {
|
||||
return self.next() catch |err| switch (err) {
|
||||
error.Overflow => unreachable,
|
||||
};
|
||||
@ -125,28 +125,28 @@ pub const varintSliceIterator = struct {
|
||||
|
||||
// returns the number of remaining items. If called before the first
|
||||
// next(), returns the length of the slice.
|
||||
pub fn remaining(self: *const varintSliceIterator) usize {
|
||||
pub fn remaining(self: *const VarintSliceIterator) usize {
|
||||
return self.remaining;
|
||||
}
|
||||
};
|
||||
|
||||
pub fn VarintSliceIterator(arr: []const u8) error{Overflow}!varintSliceIterator {
|
||||
pub fn varintSliceIterator(arr: []const u8) error{Overflow}!VarintSliceIterator {
|
||||
const firstnumber = try uvarint(arr);
|
||||
return varintSliceIterator{
|
||||
return VarintSliceIterator{
|
||||
.remaining = firstnumber.value,
|
||||
.arr = arr,
|
||||
.idx = firstnumber.bytes_read,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn VarintSliceIteratorMust(arr: []const u8) varintSliceIterator {
|
||||
return VarintSliceIterator(arr) catch |err| switch (err) {
|
||||
pub fn varintSliceIteratorMust(arr: []const u8) VarintSliceIterator {
|
||||
return varintSliceIterator(arr) catch |err| switch (err) {
|
||||
error.Overflow => unreachable,
|
||||
};
|
||||
}
|
||||
|
||||
pub const DeltaDecompressionIterator = struct {
|
||||
vit: *varintSliceIterator,
|
||||
vit: *VarintSliceIterator,
|
||||
prev: u64,
|
||||
add_to_prev: u1,
|
||||
|
||||
@ -174,7 +174,7 @@ pub const DeltaDecompressionIterator = struct {
|
||||
}
|
||||
};
|
||||
|
||||
pub fn deltaDecompressionIterator(vit: *varintSliceIterator) DeltaDecompressionIterator {
|
||||
pub fn deltaDecompressionIterator(vit: *VarintSliceIterator) DeltaDecompressionIterator {
|
||||
return DeltaDecompressionIterator{
|
||||
.vit = vit,
|
||||
.prev = 0,
|
||||
@ -219,14 +219,14 @@ test "putUvarint/uvarint" {
|
||||
}
|
||||
}
|
||||
|
||||
test "VarintSliceIterator" {
|
||||
test "varintSliceIterator" {
|
||||
var buf = ArrayList(u8).init(testing.allocator);
|
||||
defer buf.deinit();
|
||||
try appendUvarint(&buf, uvarint_tests.len);
|
||||
for (uvarint_tests) |x|
|
||||
try appendUvarint(&buf, x);
|
||||
|
||||
var it = try VarintSliceIterator(buf.items);
|
||||
var it = try varintSliceIterator(buf.items);
|
||||
var i: usize = 0;
|
||||
while (try it.next()) |got| : (i += 1) {
|
||||
try testing.expectEqual(uvarint_tests[i], got);
|
||||
@ -303,7 +303,7 @@ test "delta decompression with an iterator" {
|
||||
for (compressed) |x|
|
||||
try appendUvarint(&buf, x);
|
||||
|
||||
var vit = try VarintSliceIterator(buf.items);
|
||||
var vit = try varintSliceIterator(buf.items);
|
||||
var it = deltaDecompressionIterator(&vit);
|
||||
var i: usize = 0;
|
||||
try testing.expectEqual(it.remaining(), uvarint_tests.len);
|
||||
|
Loading…
Reference in New Issue
Block a user