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 {
191
191
const Value = std .meta .FieldType (DecodedType .KV , .value );
192
192
var map = DecodedType .init (allocator );
193
193
const map_len = field .size ;
194
- try map .ensureTotalCapacity (@intCast ( map_len ) );
194
+ try map .ensureTotalCapacity (map_len );
195
195
196
196
for (0.. map_len ) | _ | {
197
197
const key = try self .decodeValue (allocator , Key );
@@ -209,11 +209,12 @@ pub const Decoder = struct {
209
209
}
210
210
211
211
const Value = std .meta .Child (DecodedType .Slice );
212
- var array = std .ArrayList (Value ).init (allocator );
213
212
const array_len = field .size ;
213
+ var array = try std .ArrayList (Value ).initCapacity (allocator , array_len );
214
+
214
215
for (0.. array_len ) | _ | {
215
216
const value = try self .decodeValue (allocator , Value );
216
- try array .append (value );
217
+ array .appendAssumeCapacity (value );
217
218
}
218
219
219
220
return array ;
Original file line number Diff line number Diff line change 17
17
}
18
18
19
19
fn expectEqualMaps (
20
- map : std .hash_map . StringHashMap ([]const u8 ),
20
+ map : std .StringArrayHashMap ([]const u8 ),
21
21
keys : []const []const u8 ,
22
22
values : []const []const u8 ,
23
23
) ! void {
Original file line number Diff line number Diff line change @@ -175,7 +175,7 @@ pub const Reader = struct {
175
175
// start with the node we traversed to as our to be processed stack.
176
176
// Else the stack will be empty and we'll be returning an iterator that visits nothing.
177
177
if (node < node_count ) {
178
- try stack .append (WithinNode {
178
+ stack .appendAssumeCapacity (WithinNode {
179
179
.node = node ,
180
180
.ip_bytes = ip_bytes ,
181
181
.prefix_len = prefix_len ,
@@ -360,15 +360,15 @@ fn Iterator(comptime T: type) type {
360
360
}
361
361
}
362
362
363
- try self .stack .append (WithinNode {
363
+ self .stack .appendAssumeCapacity (WithinNode {
364
364
.node = node ,
365
365
.ip_bytes = right_ip_bytes ,
366
366
.prefix_len = current .prefix_len + 1 ,
367
367
});
368
368
369
369
// In order traversal of the children on the left (0-bit).
370
370
node = try reader .readNode (current .node , 0 );
371
- try self .stack .append (WithinNode {
371
+ self .stack .appendAssumeCapacity (WithinNode {
372
372
.node = node ,
373
373
.ip_bytes = current .ip_bytes ,
374
374
.prefix_len = current .prefix_len + 1 ,
You can’t perform that action at this time.
0 commit comments