diff --git a/source/command.zig b/source/command.zig index d0174a9..d98d24d 100644 --- a/source/command.zig +++ b/source/command.zig @@ -167,7 +167,7 @@ pub fn CommandBuilder(comptime UserContext: type) type { return Parser(self, callback){ .arena = arena, .allocator = arena_alloc, - .subcommands = std.hash_map.StringHashMap(ParserInterface).init(arena_alloc), + .subcommands = parser.CommandMap.init(arena_alloc), .help_builder = help.HelpBuilder(self).init(arena_alloc), }; } @@ -188,7 +188,7 @@ pub fn CommandBuilder(comptime UserContext: type) type { this_parser.* = .{ .arena = arena, .allocator = arena_alloc, - .subcommands = std.hash_map.StringHashMap(ParserInterface).init(arena_alloc), + .subcommands = parser.CommandMap.init(arena_alloc), .help_builder = help.HelpBuilder(self).init(arena_alloc), }; diff --git a/source/help.zig b/source/help.zig index 2dd157a..42657fc 100644 --- a/source/help.zig +++ b/source/help.zig @@ -360,11 +360,10 @@ pub fn HelpBuilder(comptime command: anytype) type { defer pairs.deinit(); var just: usize = 0; - var iter = subcommands.keyIterator(); - while (iter.next()) |key| { + for (subcommands.keys()) |key| { const pair: AlignablePair = .{ - .left = key.*, - .right = subcommands.get(key.*).?.describe(), + .left = key, + .right = subcommands.get(key).?.describe(), }; if (pair.left.len > just) just = pair.left.len; try pairs.append(pair); diff --git a/source/parser.zig b/source/parser.zig index de90994..0b82a09 100644 --- a/source/parser.zig +++ b/source/parser.zig @@ -73,7 +73,7 @@ pub const ParserInterface = struct { } }; -pub const CommandMap = std.hash_map.StringHashMap(ParserInterface); +pub const CommandMap = std.StringArrayHashMap(ParserInterface); // the parser is generated by the bind method of the CommandBuilder, so we can // be extremely type-sloppy here, which simplifies the signature. @@ -144,8 +144,7 @@ pub fn Parser(comptime command: anytype, comptime callback: anytype) type { } pub fn deinitTree(self: @This()) void { - var iterator = self.subcommands.valueIterator(); - while (iterator.next()) |subcommand| { + for (self.subcommands.values()) |subcommand| { subcommand.deinitTree(); } self.deinit();