forked from mirror/vulkan-zig
Remove declarations in an order-preserving way
This commit is contained in:
@@ -132,22 +132,22 @@ const DeclarationResolver = struct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Swap-remove all declarations that are not required.
|
// Remove all declarations that are not required.
|
||||||
// Some declarations may exist in `self.declarations` that do not exit in
|
// Some declarations may exist in `self.declarations` that do not exit in
|
||||||
// `self.registry.decls`, these are mostly macros and other stuff not parsed.
|
// `self.registry.decls`, these are mostly macros and other stuff not pa
|
||||||
var i: usize = 0;
|
var read_index: usize = 0;
|
||||||
var count = self.registry.decls.len;
|
var write_index: usize = 0;
|
||||||
while (i < count) {
|
while (read_index < self.registry.decls.len) {
|
||||||
const decl = self.registry.decls[i];
|
const decl = self.registry.decls[read_index];
|
||||||
if (self.declarations.contains(decl.name)) {
|
if (self.declarations.contains(decl.name)) {
|
||||||
i += 1;
|
self.registry.decls[write_index] = decl;
|
||||||
} else {
|
write_index += 1;
|
||||||
count -= 1;
|
|
||||||
self.registry.decls[i] = self.registry.decls[count];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
read_index += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.registry.decls = self.reg_arena.shrink(self.registry.decls, count);
|
self.registry.decls = self.reg_arena.shrink(self.registry.decls, write_index);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user