diff --git a/build.zig b/build.zig index fa9f6ac..ce61fee 100644 --- a/build.zig +++ b/build.zig @@ -146,7 +146,7 @@ pub fn build(b: *std.Build) !void { const tag = @tagName(target.os.tag); // Declares dependencies - Dependency.addExternal(b, "swift_lib", 0); + Dependency.addExternal(b, "swiftzig", 0); Dependency.addInternal(b, "Kivi", "src/core/Kivi.zig", 1, 0); Dependency.addInternal(b, "core", "src/core/main.zig", 2, 0); diff --git a/build.zig.zon b/build.zig.zon index f043164..3618bc3 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -4,9 +4,9 @@ .minimum_zig_version = "0.11.0", .paths = .{ "src", "build.zig", "build.zig.zon" }, .dependencies = .{ - .swift_lib = .{ - .url = "https://github.com/devraymondsh/swift_lib/archive/refs/tags/v0.3.0.tar.gz", - .hash = "12201501ad4ac2d6827b2a293219ec8a49d7d12239895f17ad00c6209b0418dad3fe", + .swiftzig = .{ + .url = "https://github.com/devraymondsh/swiftzig/archive/refs/tags/v0.4.0.tar.gz", + .hash = "12208f395f60bbb782d91309c7b6d5d0da64a41db784e227f28dfd22ae996c05abaa", }, }, } diff --git a/src/core/ByteMap.zig b/src/core/ByteMap.zig index ce01f1b..3fe261b 100644 --- a/src/core/ByteMap.zig +++ b/src/core/ByteMap.zig @@ -1,7 +1,7 @@ /// This is Byte(u8) hashmap implementation that relies on the caller to handle allocations and lifetimes. const builtin = @import("builtin"); const Wyhash = @import("./Wyhash.zig"); -const swift_lib = @import("swift_lib"); +const swiftzig = @import("swiftzig"); const Entry = struct { key: []u8, @@ -70,8 +70,8 @@ table_size: usize, var hasher = Wyhash.init(0); -pub fn init(self: *ByteMap, allocator: swift_lib.heap.Allocator, size: usize) !void { - self.table_size = swift_lib.math.ceilPowerOfTwo(size); +pub fn init(self: *ByteMap, allocator: swiftzig.mem.Allocator, size: usize) !void { + self.table_size = swiftzig.math.ceilPowerOfTwo(size); self.table_metadata = try allocator.alloc(GroupMetadata, self.table_size); self.table = try allocator.alloc(Group, self.table_size); @@ -183,7 +183,7 @@ pub fn get(self: *ByteMap, key: []const u8) ?[]u8 { } return null; } -pub fn del(self: *ByteMap, allocator: swift_lib.heap.Allocator, key: []const u8) ?[]u8 { +pub fn del(self: *ByteMap, allocator: swiftzig.mem.Allocator, key: []const u8) ?[]u8 { const found_entity = self.find_index(key, true); if (found_entity) |entity| { const entry = &self.table[entity.group_idx].elements[entity.elem_idx]; diff --git a/src/core/Kivi.zig b/src/core/Kivi.zig index 513bc36..da62ccb 100644 --- a/src/core/Kivi.zig +++ b/src/core/Kivi.zig @@ -1,5 +1,5 @@ const ByteMap = @import("ByteMap.zig"); -const swift_lib = @import("swift_lib"); +const swiftzig = @import("swiftzig"); pub const Config = extern struct { // (2 ** 18) * 16 = 4194304 @@ -8,8 +8,8 @@ pub const Config = extern struct { }; map: ByteMap, -allocator: swift_lib.heap.Allocator, -freelist: swift_lib.heap.FreelistAllocator, +allocator: swiftzig.mem.Allocator, +freelist: swiftzig.mem.FreelistAllocator, const Kivi = @This(); @@ -21,9 +21,9 @@ fn stringcpy(dest: []u8, src: []const u8) !void { } pub fn init(self: *Kivi, config: *const Config) !usize { - const pages = try swift_lib.heap.PageAllocator.init(config.mem_size / swift_lib.os.page_size); + const pages = try swiftzig.mem.PageAllocator.init(config.mem_size / swiftzig.os.page_size); - self.freelist = swift_lib.heap.FreelistAllocator.init(pages.mem); + self.freelist = swiftzig.mem.FreelistAllocator.init(pages.mem); self.allocator = self.freelist.allocator(); try self.map.init(self.allocator, config.group_size); @@ -94,7 +94,7 @@ pub fn rm(self: *Kivi, key: []const u8) !void { } pub fn deinit(self: *Kivi) void { - var pages: swift_lib.heap.PageAllocator = .{ .mem = @alignCast(self.freelist.mem) }; + var pages: swiftzig.mem.PageAllocator = .{ .mem = @alignCast(self.freelist.mem) }; self.map.deinit(); pages.deinit();