File tree Expand file tree Collapse file tree 3 files changed +8
-7
lines changed
Expand file tree Collapse file tree 3 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -191,7 +191,7 @@ pub const Decoder = struct {
191191 const Value = std .meta .FieldType (DecodedType .KV , .value );
192192 var map = DecodedType .init (allocator );
193193 const map_len = field .size ;
194- try map .ensureTotalCapacity (@intCast ( map_len ) );
194+ try map .ensureTotalCapacity (map_len );
195195
196196 for (0.. map_len ) | _ | {
197197 const key = try self .decodeValue (allocator , Key );
@@ -209,11 +209,12 @@ pub const Decoder = struct {
209209 }
210210
211211 const Value = std .meta .Child (DecodedType .Slice );
212- var array = std .ArrayList (Value ).init (allocator );
213212 const array_len = field .size ;
213+ var array = try std .ArrayList (Value ).initCapacity (allocator , array_len );
214+
214215 for (0.. array_len ) | _ | {
215216 const value = try self .decodeValue (allocator , Value );
216- try array .append (value );
217+ array .appendAssumeCapacity (value );
217218 }
218219
219220 return array ;
Original file line number Diff line number Diff line change 1717}
1818
1919fn expectEqualMaps (
20- map : std .hash_map . StringHashMap ([]const u8 ),
20+ map : std .StringArrayHashMap ([]const u8 ),
2121 keys : []const []const u8 ,
2222 values : []const []const u8 ,
2323) ! void {
Original file line number Diff line number Diff line change @@ -175,7 +175,7 @@ pub const Reader = struct {
175175 // start with the node we traversed to as our to be processed stack.
176176 // Else the stack will be empty and we'll be returning an iterator that visits nothing.
177177 if (node < node_count ) {
178- try stack .append (WithinNode {
178+ stack .appendAssumeCapacity (WithinNode {
179179 .node = node ,
180180 .ip_bytes = ip_bytes ,
181181 .prefix_len = prefix_len ,
@@ -360,15 +360,15 @@ fn Iterator(comptime T: type) type {
360360 }
361361 }
362362
363- try self .stack .append (WithinNode {
363+ self .stack .appendAssumeCapacity (WithinNode {
364364 .node = node ,
365365 .ip_bytes = right_ip_bytes ,
366366 .prefix_len = current .prefix_len + 1 ,
367367 });
368368
369369 // In order traversal of the children on the left (0-bit).
370370 node = try reader .readNode (current .node , 0 );
371- try self .stack .append (WithinNode {
371+ self .stack .appendAssumeCapacity (WithinNode {
372372 .node = node ,
373373 .ip_bytes = current .ip_bytes ,
374374 .prefix_len = current .prefix_len + 1 ,
You can’t perform that action at this time.
0 commit comments