Skip to content

Commit 99f3bc6

Browse files
committed
Code cleanup
1 parent 2c31dbc commit 99f3bc6

File tree

2 files changed

+5
-21
lines changed

2 files changed

+5
-21
lines changed

src/Index.zig

+5-1
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,13 @@ fn stopCheckpointThread(self: *Self) void {
260260
}
261261

262262
fn updateManifestFile(self: *Self, segments: *FileSegmentList) !void {
263-
const infos = try segments.getInfos(self.allocator);
263+
const infos = try self.allocator.alloc(SegmentInfo, segments.nodes.items.len);
264264
defer self.allocator.free(infos);
265265

266+
for (segments.nodes.items, 0..) |node, i| {
267+
infos[i] = node.value.info;
268+
}
269+
266270
try filefmt.writeManifestFile(self.dir, infos);
267271
}
268272

src/segment_list.zig

-20
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,6 @@ pub fn SegmentList(Segment: type) type {
100100
}
101101
}
102102

103-
pub fn getInfos(self: Self, allocator: Allocator) Allocator.Error![]SegmentInfo {
104-
var infos = try allocator.alloc(SegmentInfo, self.nodes.items.len);
105-
for (self.nodes.items, 0..) |node, i| {
106-
infos[i] = node.value.info;
107-
}
108-
return infos;
109-
}
110-
111103
pub fn search(self: Self, hashes: []const u32, results: *SearchResults, deadline: Deadline) !void {
112104
for (self.nodes.items) |node| {
113105
if (deadline.isExpired()) {
@@ -118,14 +110,6 @@ pub fn SegmentList(Segment: type) type {
118110
results.removeOutdatedResults(self);
119111
}
120112

121-
pub fn getMaxCommitId(self: Self) u64 {
122-
var max_commit_id: u64 = 0;
123-
for (self.nodes.items) |node| {
124-
max_commit_id = @max(max_commit_id, node.value.max_commit_id);
125-
}
126-
return max_commit_id;
127-
}
128-
129113
fn compareByVersion(_: void, lhs: u32, rhs: Node) bool {
130114
return lhs < rhs.value.id.version;
131115
}
@@ -146,10 +130,6 @@ pub fn SegmentList(Segment: type) type {
146130
return false;
147131
}
148132

149-
pub fn count(self: Self) usize {
150-
return self.nodes.items.len;
151-
}
152-
153133
pub fn getFirst(self: Self) ?Node {
154134
return if (self.nodes.items.len > 0) self.nodes.items[0] else null;
155135
}

0 commit comments

Comments
 (0)