Merge pull request #3 from joachimschmidt557/hashmap-api

Update to latest HashMap API
master
prime31 4 years ago committed by GitHub
commit d5bfda0a64

@ -195,8 +195,7 @@ pub const Registry = struct {
} }
pub fn deinit(self: *Registry) void { pub fn deinit(self: *Registry) void {
var it = self.components.iterator(); for (self.components.items()) |ptr| {
while (it.next()) |ptr| {
// HACK: we dont know the Type here but we need to call deinit // HACK: we dont know the Type here but we need to call deinit
var storage = @intToPtr(*Storage(u1), ptr.value); var storage = @intToPtr(*Storage(u1), ptr.value);
storage.deinit(); storage.deinit();
@ -343,8 +342,7 @@ pub const Registry = struct {
pub fn removeAll(self: *Registry, entity: Entity) void { pub fn removeAll(self: *Registry, entity: Entity) void {
assert(self.valid(entity)); assert(self.valid(entity));
var it = self.components.iterator(); for (self.components.items()) |ptr| {
while (it.next()) |ptr| {
// HACK: we dont know the Type here but we need to be able to call methods on the Storage(T) // HACK: we dont know the Type here but we need to be able to call methods on the Storage(T)
var store = @intToPtr(*Storage(u1), ptr.value); var store = @intToPtr(*Storage(u1), ptr.value);
store.removeIfContains(entity); store.removeIfContains(entity);

@ -14,8 +14,7 @@ pub const TypeStore = struct {
} }
pub fn deinit(self: *TypeStore) void { pub fn deinit(self: *TypeStore) void {
var iter = self.map.iterator(); for (self.map.items()) |kv| {
while (iter.next()) |kv| {
self.allocator.free(kv.value); self.allocator.free(kv.value);
} }
self.map.deinit(); self.map.deinit();

@ -14,8 +14,7 @@ pub const Assets = struct {
} }
pub fn deinit(self: *Assets) void { pub fn deinit(self: *Assets) void {
var it = self.caches.iterator(); for (self.caches.items()) |ptr| {
while (it.next()) |ptr| {
// HACK: we dont know the Type here but we need to call deinit // HACK: we dont know the Type here but we need to call deinit
@intToPtr(*Cache(u1), ptr.value).deinit(); @intToPtr(*Cache(u1), ptr.value).deinit();
} }

@ -67,8 +67,7 @@ pub fn Cache(comptime T: type) type {
pub fn clear(self: *@This()) void { pub fn clear(self: *@This()) void {
// optionally deinit any resources that have a deinit method // optionally deinit any resources that have a deinit method
if (@hasDecl(T, "deinit")) { if (@hasDecl(T, "deinit")) {
var iter = self.resources.iterator(); for (self.resources.items()) |kv| {
while (iter.next()) |kv| {
@call(.{ .modifier = .always_inline }, @field(kv.value, "deinit"), .{}); @call(.{ .modifier = .always_inline }, @field(kv.value, "deinit"), .{});
} }
} }

@ -15,8 +15,7 @@ pub const Dispatcher = struct {
} }
pub fn deinit(self: *Dispatcher) void { pub fn deinit(self: *Dispatcher) void {
var it = self.signals.iterator(); for (self.signals.items()) |ptr| {
while (it.next()) |ptr| {
// HACK: we dont know the Type here but we need to call deinit // HACK: we dont know the Type here but we need to call deinit
var signal = @intToPtr(*Signal(void), ptr.value); var signal = @intToPtr(*Signal(void), ptr.value);
signal.deinit(); signal.deinit();

Loading…
Cancel
Save