Skip to content

Commit 731585f

Browse files
refactor(util): update tree algorithms
- update test include filter - duplicate node contents in tree node - update debug statements
1 parent a20fe50 commit 731585f

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

src/util.zig

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,16 @@ const TREE_NODE = struct {
1616
allocator: STD.mem.Allocator,
1717
node_options: struct {
1818
parent: *TREE_NODE = undefined,
19-
node_contents: []const u8 = "empty",
19+
node_contents: []const u8 = "",
2020
},
2121
) !*TREE_NODE {
2222
const TREE_NODE_INSTANCE = try allocator.create(TREE_NODE);
2323

24-
const DUPLICATED_CHILD_CONTENT = try allocator.dupe(u8, node_options.node_contents);
25-
TREE_NODE_INSTANCE.node_contents = DUPLICATED_CHILD_CONTENT;
26-
2724
TREE_NODE_INSTANCE.parent = node_options.parent;
2825
TREE_NODE_INSTANCE.children = .empty;
2926

27+
TREE_NODE_INSTANCE.node_contents = try allocator.dupe(u8, node_options.node_contents);
28+
3029
return TREE_NODE_INSTANCE;
3130
}
3231

@@ -182,10 +181,10 @@ pub const DIR_TREE = struct {
182181
STD.debug.print("\n[\n", .{});
183182

184183
for (debug_nodes_list.items) |item| {
185-
STD.debug.print("{s},", .{item});
184+
STD.debug.print("{s},\n", .{item});
186185
}
187186

188-
STD.debug.print("\n]\n", .{});
187+
STD.debug.print("]\n\n", .{});
189188
}
190189
}
191190

@@ -341,7 +340,7 @@ test "build and search solutions directory tree" {
341340

342341
try DIR_TREE_INSTANCE.iterateAndFilterTree(ALLOCATOR, .{
343342
.is_debug_enabled = false,
344-
.include_filter = "src",
343+
.include_filter = ".cpp",
345344
});
346345
}
347346

0 commit comments

Comments
 (0)