bdz/cmph nits
This commit is contained in:
@@ -35,7 +35,7 @@ pub fn pack(allocator: Allocator, input: [][*:0]const u8) Error![]const u8 {
|
||||
}
|
||||
|
||||
// perfect-hash a list of numbers and return the packed mphf
|
||||
pub fn pack_u32(allocator: Allocator, numbers: []const u32) Error![]const u8 {
|
||||
pub fn packU32(allocator: Allocator, numbers: []const u32) Error![]const u8 {
|
||||
var keys: [][6]u8 = try allocator.alloc([6]u8, numbers.len);
|
||||
defer allocator.free(keys);
|
||||
for (numbers) |n, i|
|
||||
@@ -49,7 +49,7 @@ pub fn pack_u32(allocator: Allocator, numbers: []const u32) Error![]const u8 {
|
||||
}
|
||||
|
||||
// perfect-hash a list of strings and return the packed mphf
|
||||
pub fn pack_str(allocator: Allocator, strings: []const []const u8) Error![]const u8 {
|
||||
pub fn packStr(allocator: Allocator, strings: []const []const u8) Error![]const u8 {
|
||||
var arena = std.heap.ArenaAllocator.init(allocator);
|
||||
defer arena.deinit();
|
||||
var keys = try arena.allocator().alloc([*:0]const u8, strings.len);
|
||||
@@ -119,7 +119,7 @@ test "unzeroZ" {
|
||||
|
||||
test "pack u32" {
|
||||
const keys = &[_]u32{ 42, 1, math.maxInt(u32), 2 };
|
||||
const packed_mphf = try pack_u32(testing.allocator, keys);
|
||||
const packed_mphf = try packU32(testing.allocator, keys);
|
||||
defer testing.allocator.free(packed_mphf);
|
||||
var hashes: [keys.len]u32 = undefined;
|
||||
for (keys) |key, i| {
|
||||
@@ -132,7 +132,7 @@ test "pack u32" {
|
||||
|
||||
test "pack str" {
|
||||
const keys = &[_][]const u8{ "foo", "bar", "baz", "1", "2", "3" };
|
||||
const packed_mphf = try pack_str(testing.allocator, keys[0..]);
|
||||
const packed_mphf = try packStr(testing.allocator, keys[0..]);
|
||||
defer testing.allocator.free(packed_mphf);
|
||||
var hashes: [keys.len]u32 = undefined;
|
||||
for (keys) |key, i| {
|
||||
|
||||
Reference in New Issue
Block a user