remove unused capacity from Ast and DocumentStore (#941)

This commit is contained in:
Techatrix 2023-01-26 22:57:07 +01:00 committed by GitHub
parent 6019eff13e
commit e055f9d15c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -622,9 +622,19 @@ fn createDocument(self: *DocumentStore, uri: Uri, text: [:0]u8, open: bool) erro
var tree = try std.zig.parse(self.allocator, text);
errdefer tree.deinit(self.allocator);
var nodes = tree.nodes.toMultiArrayList();
try nodes.setCapacity(self.allocator, nodes.len);
tree.nodes = nodes.slice();
var tokens = tree.tokens.toMultiArrayList();
try tokens.setCapacity(self.allocator, tokens.len);
tree.tokens = tokens.slice();
var document_scope = try analysis.makeDocumentScope(self.allocator, tree);
errdefer document_scope.deinit(self.allocator);
try document_scope.scopes.setCapacity(self.allocator, document_scope.scopes.len);
break :blk Handle{
.open = open,
.uri = duped_uri,