Remove unused variables and redudant comptime
s
Latest version tested: 0.9.0-dev.339+81bf05bf6
This commit is contained in:
parent
44192a1398
commit
33a5344b10
@ -63,7 +63,7 @@ pub fn getPackage(comptime prefix_path: []const u8) std.build.Pkg {
|
||||
}
|
||||
|
||||
/// prefix_path is used to add package paths. It should be the the same path used to include this build file
|
||||
pub fn linkArtifact(b: *Builder, artifact: *std.build.LibExeObjStep, target: std.build.Target, lib_type: LibType, comptime prefix_path: []const u8) void {
|
||||
pub fn linkArtifact(b: *Builder, artifact: *std.build.LibExeObjStep, _: std.build.Target, lib_type: LibType, comptime prefix_path: []const u8) void {
|
||||
const build_mode = b.standardReleaseOptions();
|
||||
switch (lib_type) {
|
||||
.static => {
|
||||
|
@ -11,7 +11,7 @@ pub fn ComponentStorage(comptime Component: type, comptime Entity: type) type {
|
||||
std.debug.assert(!utils.isComptime(Component));
|
||||
|
||||
// empty (zero-sized) structs will not have an array created
|
||||
comptime const is_empty_struct = @sizeOf(Component) == 0;
|
||||
const is_empty_struct = @sizeOf(Component) == 0;
|
||||
|
||||
// HACK: due to this being stored as untyped ptrs, when deinit is called we are casted to a Component of some random
|
||||
// non-zero sized type. That will make is_empty_struct false in deinit always so we can't use it. Instead, we stick
|
||||
@ -391,16 +391,16 @@ test "sort empty component" {
|
||||
store.add(2, Empty{});
|
||||
store.add(0, Empty{});
|
||||
|
||||
comptime const asc_u32 = std.sort.asc(u32);
|
||||
const asc_u32 = comptime std.sort.asc(u32);
|
||||
store.sort(u32, {}, asc_u32);
|
||||
for (store.data()) |e, i| {
|
||||
try std.testing.expectEqual(@intCast(u32, i), e);
|
||||
}
|
||||
|
||||
comptime const desc_u32 = std.sort.desc(u32);
|
||||
const desc_u32 = comptime std.sort.desc(u32);
|
||||
store.sort(u32, {}, desc_u32);
|
||||
var counter: u32 = 2;
|
||||
for (store.data()) |e, i| {
|
||||
for (store.data()) |e| {
|
||||
try std.testing.expectEqual(counter, e);
|
||||
if (counter > 0) counter -= 1;
|
||||
}
|
||||
@ -427,7 +427,7 @@ test "sort by entity" {
|
||||
store.sort(u32, store.len(), context, SortContext.sort);
|
||||
|
||||
var compare: f32 = 5;
|
||||
for (store.raw()) |val, i| {
|
||||
for (store.raw()) |val| {
|
||||
try std.testing.expect(compare > val);
|
||||
compare = val;
|
||||
}
|
||||
@ -441,11 +441,11 @@ test "sort by component" {
|
||||
store.add(11, @as(f32, 1.1));
|
||||
store.add(33, @as(f32, 3.3));
|
||||
|
||||
comptime const desc_f32 = std.sort.desc(f32);
|
||||
const desc_f32 = comptime std.sort.desc(f32);
|
||||
store.sort(f32, store.len(), {}, desc_f32);
|
||||
|
||||
var compare: f32 = 5;
|
||||
for (store.raw()) |val, i| {
|
||||
for (store.raw()) |val| {
|
||||
try std.testing.expect(compare > val);
|
||||
compare = val;
|
||||
}
|
||||
|
@ -287,13 +287,13 @@ test "BasicGroup creation/iteration" {
|
||||
|
||||
var iterated_entities: usize = 0;
|
||||
var iter = group.iterator();
|
||||
while (iter.next()) |entity| {
|
||||
while (iter.next()) |_| {
|
||||
iterated_entities += 1;
|
||||
}
|
||||
try std.testing.expectEqual(iterated_entities, 1);
|
||||
|
||||
iterated_entities = 0;
|
||||
for (group.data()) |entity| {
|
||||
for (group.data()) |_| {
|
||||
iterated_entities += 1;
|
||||
}
|
||||
try std.testing.expectEqual(iterated_entities, 1);
|
||||
@ -316,7 +316,7 @@ test "BasicGroup excludes" {
|
||||
|
||||
var iterated_entities: usize = 0;
|
||||
var iter = group.iterator();
|
||||
while (iter.next()) |entity| {
|
||||
while (iter.next()) |_| {
|
||||
iterated_entities += 1;
|
||||
}
|
||||
try std.testing.expectEqual(iterated_entities, 1);
|
||||
@ -422,7 +422,7 @@ test "OwningGroup each" {
|
||||
reg.add(e0, @as(u32, 55));
|
||||
|
||||
const Thing = struct {
|
||||
fn each(self: @This(), components: struct {
|
||||
fn each(_: @This(), components: struct {
|
||||
int: *i32,
|
||||
uint: *u32,
|
||||
}) void {
|
||||
@ -449,9 +449,9 @@ test "multiple OwningGroups" {
|
||||
// var group1 = reg.group(.{u64, u32}, .{}, .{});
|
||||
// var group2 = reg.group(.{u64, u32, u8}, .{}, .{});
|
||||
|
||||
var group5 = reg.group(.{ Sprite, Transform }, .{ Renderable, Rotation }, .{});
|
||||
var group3 = reg.group(.{Sprite}, .{Renderable}, .{});
|
||||
var group4 = reg.group(.{ Sprite, Transform }, .{Renderable}, .{});
|
||||
_ = reg.group(.{ Sprite, Transform }, .{ Renderable, Rotation }, .{});
|
||||
_ = reg.group(.{Sprite}, .{Renderable}, .{});
|
||||
_ = reg.group(.{ Sprite, Transform }, .{Renderable}, .{});
|
||||
|
||||
// ensure groups are ordered correctly internally
|
||||
var last_size: u8 = 0;
|
||||
|
@ -58,11 +58,11 @@ pub fn Handles(comptime HandleType: type, comptime IndexType: type, comptime Ver
|
||||
self.allocator.free(self.handles);
|
||||
}
|
||||
|
||||
pub fn extractId(self: Self, handle: HandleType) IndexType {
|
||||
pub fn extractId(_: Self, handle: HandleType) IndexType {
|
||||
return @truncate(IndexType, handle);
|
||||
}
|
||||
|
||||
pub fn extractVersion(self: Self, handle: HandleType) VersionType {
|
||||
pub fn extractVersion(_: Self, handle: HandleType) VersionType {
|
||||
return @truncate(VersionType, handle >> @bitSizeOf(IndexType));
|
||||
}
|
||||
|
||||
|
@ -255,12 +255,12 @@ pub const Registry = struct {
|
||||
}
|
||||
|
||||
/// Returns the entity identifier without the version
|
||||
pub fn entityId(self: Registry, entity: Entity) Entity {
|
||||
pub fn entityId(_: Registry, entity: Entity) Entity {
|
||||
return entity & entity_traits.entity_mask;
|
||||
}
|
||||
|
||||
/// Returns the version stored along with an entity identifier
|
||||
pub fn version(self: *Registry, entity: Entity) entity_traits.version_type {
|
||||
pub fn version(_: *Registry, entity: Entity) entity_traits.version_type {
|
||||
return @truncate(entity_traits.version_type, entity >> @bitSizeOf(entity_traits.index_type));
|
||||
}
|
||||
|
||||
@ -471,7 +471,7 @@ pub const Registry = struct {
|
||||
std.debug.assert(owned.len + includes.len + excludes.len > 1);
|
||||
|
||||
// create a unique hash to identify the group so that we can look it up
|
||||
comptime const hash = comptime hashGroupTypes(owned, includes, excludes);
|
||||
const hash = comptime hashGroupTypes(owned, includes, excludes);
|
||||
|
||||
for (self.groups.items) |grp| {
|
||||
if (grp.hash == hash) {
|
||||
@ -606,9 +606,9 @@ pub const Registry = struct {
|
||||
}
|
||||
}
|
||||
|
||||
const owned_str = comptime concatTypes(owned);
|
||||
const includes_str = comptime concatTypes(includes);
|
||||
const excludes_str = comptime concatTypes(excludes);
|
||||
const owned_str = concatTypes(owned);
|
||||
const includes_str = concatTypes(includes);
|
||||
const excludes_str = concatTypes(excludes);
|
||||
|
||||
return utils.hashStringFnv(u64, owned_str ++ includes_str ++ excludes_str);
|
||||
}
|
||||
@ -620,7 +620,7 @@ pub const Registry = struct {
|
||||
if (types.len == 0) return "_";
|
||||
|
||||
const impl = struct {
|
||||
fn asc(context: void, lhs: []const u8, rhs: []const u8) bool {
|
||||
fn asc(_: void, lhs: []const u8, rhs: []const u8) bool {
|
||||
return std.mem.lessThan(u8, lhs, rhs);
|
||||
}
|
||||
};
|
||||
|
@ -35,7 +35,7 @@ pub fn SparseSet(comptime SparseT: type) type {
|
||||
|
||||
pub fn deinit(self: *Self) void {
|
||||
self.sparse.expandToCapacity();
|
||||
for (self.sparse.items) |array, i| {
|
||||
for (self.sparse.items) |array| {
|
||||
if (array) |arr| {
|
||||
self.sparse.allocator.free(arr);
|
||||
}
|
||||
@ -53,7 +53,7 @@ pub fn SparseSet(comptime SparseT: type) type {
|
||||
return (sparse & self.entity_mask) / entity_per_page;
|
||||
}
|
||||
|
||||
fn offset(self: Self, sparse: SparseT) usize {
|
||||
fn offset(_: Self, sparse: SparseT) usize {
|
||||
return sparse & (entity_per_page - 1);
|
||||
}
|
||||
|
||||
@ -151,7 +151,7 @@ pub fn SparseSet(comptime SparseT: type) type {
|
||||
pub fn sort(self: *Self, context: anytype, comptime lessThan: fn (@TypeOf(context), SparseT, SparseT) bool) void {
|
||||
std.sort.insertionSort(SparseT, self.dense.items, context, lessThan);
|
||||
|
||||
for (self.dense.items) |sparse, i| {
|
||||
for (self.dense.items) |_, i| {
|
||||
const item = @intCast(SparseT, i);
|
||||
self.sparse.items[self.page(self.dense.items[self.page(item)])].?[self.offset(self.dense.items[self.page(item)])] = @intCast(SparseT, i);
|
||||
}
|
||||
@ -162,7 +162,7 @@ pub fn SparseSet(comptime SparseT: type) type {
|
||||
pub fn arrange(self: *Self, length: usize, context: anytype, comptime lessThan: fn (@TypeOf(context), SparseT, SparseT) bool, swap_context: anytype) void {
|
||||
std.sort.insertionSort(SparseT, self.dense.items[0..length], context, lessThan);
|
||||
|
||||
for (self.dense.items[0..length]) |sparse, pos| {
|
||||
for (self.dense.items[0..length]) |_, pos| {
|
||||
var curr = @intCast(SparseT, pos);
|
||||
var next = self.index(self.dense.items[curr]);
|
||||
|
||||
|
@ -84,6 +84,6 @@ test "TypeStore" {
|
||||
try std.testing.expectEqual(v3.*, 0);
|
||||
v3.* = 777;
|
||||
|
||||
var v4 = store.get(u32);
|
||||
_ = store.get(u32);
|
||||
try std.testing.expectEqual(v3.*, 777);
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ pub fn MultiView(comptime n_includes: usize, comptime n_excludes: usize) type {
|
||||
}
|
||||
|
||||
const asc_usize = struct {
|
||||
fn sort(ctx: void, a: usize, b: usize) bool {
|
||||
fn sort(_: void, a: usize, b: usize) bool {
|
||||
return a < b;
|
||||
}
|
||||
};
|
||||
@ -235,12 +235,12 @@ test "basic multi view" {
|
||||
reg.add(e0, @as(u32, 0));
|
||||
reg.add(e2, @as(u32, 2));
|
||||
|
||||
var single_view = reg.view(.{u32}, .{});
|
||||
_ = reg.view(.{u32}, .{});
|
||||
var view = reg.view(.{ i32, u32 }, .{});
|
||||
|
||||
var iterated_entities: usize = 0;
|
||||
var iter = view.iterator();
|
||||
while (iter.next()) |entity| {
|
||||
while (iter.next()) |_| {
|
||||
iterated_entities += 1;
|
||||
}
|
||||
|
||||
@ -250,7 +250,7 @@ test "basic multi view" {
|
||||
reg.remove(u32, e0);
|
||||
|
||||
iter.reset();
|
||||
while (iter.next()) |entity| {
|
||||
while (iter.next()) |_| {
|
||||
iterated_entities += 1;
|
||||
}
|
||||
|
||||
@ -278,7 +278,7 @@ test "basic multi view with excludes" {
|
||||
|
||||
var iterated_entities: usize = 0;
|
||||
var iter = view.iterator();
|
||||
while (iter.next()) |entity| {
|
||||
while (iter.next()) |_| {
|
||||
iterated_entities += 1;
|
||||
}
|
||||
|
||||
@ -288,7 +288,7 @@ test "basic multi view with excludes" {
|
||||
reg.remove(u8, e2);
|
||||
|
||||
iter.reset();
|
||||
while (iter.next()) |entity| {
|
||||
while (iter.next()) |_| {
|
||||
iterated_entities += 1;
|
||||
}
|
||||
|
||||
|
@ -149,27 +149,27 @@ test "" {
|
||||
}
|
||||
|
||||
fn start(process: *Process) void {
|
||||
const self = process.getParent(@This());
|
||||
_ = process.getParent(@This());
|
||||
// std.debug.warn("start {}\n", .{self.fart});
|
||||
}
|
||||
|
||||
fn aborted(process: *Process) void {
|
||||
const self = process.getParent(@This());
|
||||
_ = process.getParent(@This());
|
||||
// std.debug.warn("aborted {}\n", .{self.fart});
|
||||
}
|
||||
|
||||
fn failed(process: *Process) void {
|
||||
const self = process.getParent(@This());
|
||||
_ = process.getParent(@This());
|
||||
// std.debug.warn("failed {}\n", .{self.fart});
|
||||
}
|
||||
|
||||
fn succeeded(process: *Process) void {
|
||||
const self = process.getParent(@This());
|
||||
_ = process.getParent(@This());
|
||||
// std.debug.warn("succeeded {}\n", .{self.fart});
|
||||
}
|
||||
|
||||
fn update(process: *Process) void {
|
||||
const self = process.getParent(@This());
|
||||
_ = process.getParent(@This());
|
||||
// std.debug.warn("update {}\n", .{self.fart});
|
||||
process.succeed();
|
||||
}
|
||||
@ -190,11 +190,11 @@ test "scheduler.clear" {
|
||||
const Tester = struct {
|
||||
process: Process,
|
||||
|
||||
pub fn initialize(self: *@This(), data: anytype) void {
|
||||
pub fn initialize(self: *@This(), _: anytype) void {
|
||||
self.process = .{ .updateFn = update };
|
||||
}
|
||||
|
||||
fn update(process: *Process) void {
|
||||
fn update(_: *Process) void {
|
||||
std.debug.assert(false);
|
||||
}
|
||||
};
|
||||
|
@ -62,13 +62,13 @@ test "assets" {
|
||||
};
|
||||
|
||||
const OtherThingLoadArgs = struct {
|
||||
pub fn load(self: @This()) *OtherThing {
|
||||
pub fn load(_: @This()) *OtherThing {
|
||||
return std.testing.allocator.create(OtherThing) catch unreachable;
|
||||
}
|
||||
};
|
||||
|
||||
const ThingLoadArgs = struct {
|
||||
pub fn load(self: @This()) *Thing {
|
||||
pub fn load(_: @This()) *Thing {
|
||||
return std.testing.allocator.create(Thing) catch unreachable;
|
||||
}
|
||||
};
|
||||
@ -76,16 +76,16 @@ test "assets" {
|
||||
var assets = Assets.init(std.testing.allocator);
|
||||
defer assets.deinit();
|
||||
|
||||
var thing = assets.get(Thing).load(6, ThingLoadArgs{});
|
||||
_ = assets.get(Thing).load(6, ThingLoadArgs{});
|
||||
try std.testing.expectEqual(assets.get(Thing).size(), 1);
|
||||
|
||||
var thing2 = assets.load(4, ThingLoadArgs{});
|
||||
_ = assets.load(4, ThingLoadArgs{});
|
||||
try std.testing.expectEqual(assets.get(Thing).size(), 2);
|
||||
|
||||
var other_thing = assets.get(OtherThing).load(6, OtherThingLoadArgs{});
|
||||
_ = assets.get(OtherThing).load(6, OtherThingLoadArgs{});
|
||||
try std.testing.expectEqual(assets.get(OtherThing).size(), 1);
|
||||
|
||||
var other_thing2 = assets.load(8, OtherThingLoadArgs{});
|
||||
_ = assets.load(8, OtherThingLoadArgs{});
|
||||
try std.testing.expectEqual(assets.get(OtherThing).size(), 2);
|
||||
|
||||
assets.get(OtherThing).clear();
|
||||
|
@ -93,6 +93,7 @@ test "cache" {
|
||||
|
||||
const ThingLoadArgs = struct {
|
||||
pub fn load(self: @This()) *Thing {
|
||||
_ = self;
|
||||
return std.testing.allocator.create(Thing) catch unreachable;
|
||||
}
|
||||
};
|
||||
@ -100,8 +101,8 @@ test "cache" {
|
||||
var cache = Cache(Thing).init(std.testing.allocator);
|
||||
defer cache.deinit();
|
||||
|
||||
var thing = cache.load(utils.hashString("my/id"), ThingLoadArgs{});
|
||||
var thing2 = cache.load(utils.hashString("another/id"), ThingLoadArgs{});
|
||||
_ = cache.load(utils.hashString("my/id"), ThingLoadArgs{});
|
||||
_ = cache.load(utils.hashString("another/id"), ThingLoadArgs{});
|
||||
try std.testing.expectEqual(cache.size(), 2);
|
||||
|
||||
cache.remove(utils.hashString("my/id"));
|
||||
|
@ -69,7 +69,7 @@ fn tester(param: u32) void {
|
||||
const Thing = struct {
|
||||
field: f32 = 0,
|
||||
|
||||
pub fn tester(self: *Thing, param: u32) void {
|
||||
pub fn tester(_: *Thing, param: u32) void {
|
||||
std.testing.expectEqual(@as(u32, 777), param) catch unreachable;
|
||||
}
|
||||
};
|
||||
|
@ -64,7 +64,7 @@ fn tester(param: u32) void {
|
||||
const Thing = struct {
|
||||
field: f32 = 0,
|
||||
|
||||
pub fn tester(self: *Thing, param: u32) void {
|
||||
pub fn tester(_: *Thing, param: u32) void {
|
||||
std.testing.expectEqual(@as(u32, 666), param) catch unreachable;
|
||||
}
|
||||
};
|
||||
|
@ -58,7 +58,7 @@ pub fn Sink(comptime Event: type) type {
|
||||
}
|
||||
}
|
||||
|
||||
fn indexOf(self: Self, callback: fn (Event) void) ?usize {
|
||||
fn indexOf(_: Self, callback: fn (Event) void) ?usize {
|
||||
for (owning_signal.calls.items) |call, i| {
|
||||
if (call.containsFree(callback)) {
|
||||
return i;
|
||||
@ -67,7 +67,7 @@ pub fn Sink(comptime Event: type) type {
|
||||
return null;
|
||||
}
|
||||
|
||||
fn indexOfBound(self: Self, ctx: anytype) ?usize {
|
||||
fn indexOfBound(_: Self, ctx: anytype) ?usize {
|
||||
for (owning_signal.calls.items) |call, i| {
|
||||
if (call.containsBound(ctx)) {
|
||||
return i;
|
||||
@ -85,7 +85,7 @@ fn tester(param: u32) void {
|
||||
const Thing = struct {
|
||||
field: f32 = 0,
|
||||
|
||||
pub fn tester(self: *Thing, param: u32) void {
|
||||
pub fn tester(_: *Thing, param: u32) void {
|
||||
std.testing.expectEqual(@as(u32, 666), param) catch unreachable;
|
||||
}
|
||||
};
|
||||
|
@ -12,11 +12,11 @@ fn tester2(param: i32) void {
|
||||
const Thing = struct {
|
||||
field: f32 = 0,
|
||||
|
||||
pub fn testU32(self: *Thing, param: u32) void {
|
||||
pub fn testU32(_: *Thing, param: u32) void {
|
||||
std.testing.expectEqual(@as(u32, 666), param) catch unreachable;
|
||||
}
|
||||
|
||||
pub fn testI32(self: *Thing, param: i32) void {
|
||||
pub fn testI32(_: *Thing, param: i32) void {
|
||||
std.testing.expectEqual(@as(i32, -543), param) catch unreachable;
|
||||
}
|
||||
};
|
||||
|
@ -70,7 +70,7 @@ test "sort BasicGroup by Component" {
|
||||
}
|
||||
|
||||
const SortContext = struct {
|
||||
fn sort(this: void, a: Sprite, b: Sprite) bool {
|
||||
fn sort(_: void, a: Sprite, b: Sprite) bool {
|
||||
return a.x > b.x;
|
||||
}
|
||||
};
|
||||
@ -131,7 +131,7 @@ test "sort OwningGroup by Component" {
|
||||
}
|
||||
|
||||
const SortContext = struct {
|
||||
fn sort(this: void, a: Sprite, b: Sprite) bool {
|
||||
fn sort(_: void, a: Sprite, b: Sprite) bool {
|
||||
return a.x > b.x;
|
||||
}
|
||||
};
|
||||
@ -165,7 +165,7 @@ test "sort OwningGroup by Component ensure unsorted non-matches" {
|
||||
try std.testing.expectEqual(reg.len(Sprite), 10);
|
||||
|
||||
const SortContext = struct {
|
||||
fn sort(this: void, a: Sprite, b: Sprite) bool {
|
||||
fn sort(_: void, a: Sprite, b: Sprite) bool {
|
||||
// sprites with x > 50 shouldnt match in the group
|
||||
std.testing.expect(a.x < 50 and b.x < 50) catch unreachable;
|
||||
return a.x > b.x;
|
||||
@ -231,8 +231,8 @@ test "nested OwningGroups entity order" {
|
||||
try std.testing.expectEqual(group1.len(), 5);
|
||||
try std.testing.expectEqual(group2.len(), 0);
|
||||
|
||||
var sprite_store = reg.assure(Sprite);
|
||||
var transform_store = reg.assure(Transform);
|
||||
_ = reg.assure(Sprite);
|
||||
_ = reg.assure(Transform);
|
||||
// printStore(sprite_store, "Sprite");
|
||||
|
||||
reg.add(1, Transform{ .x = 1 });
|
||||
|
@ -8,7 +8,7 @@ const Empty = struct {};
|
||||
const BigOne = struct { pos: Position, vel: Velocity, accel: Velocity };
|
||||
|
||||
test "entity traits" {
|
||||
const traits = ecs.EntityTraitsType(.large).init();
|
||||
_ = ecs.EntityTraitsType(.large).init();
|
||||
}
|
||||
|
||||
test "Registry" {
|
||||
@ -54,6 +54,7 @@ test "context not pointer" {
|
||||
defer reg.deinit();
|
||||
|
||||
var pos = Position{ .x = 5, .y = 5 };
|
||||
_ = pos;
|
||||
// reg.setContext(pos);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user