Skip to content

Commit

Permalink
#124 remove redundant ecs_iter_t::type field (can be obtained from ta…
Browse files Browse the repository at this point in the history
…ble)
  • Loading branch information
SanderMertens committed May 5, 2022
1 parent 5540393 commit 90ad5f8
Show file tree
Hide file tree
Showing 19 changed files with 35,536 additions and 35,553 deletions.
2 changes: 1 addition & 1 deletion examples/c/hello_world/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void Move(ecs_iter_t *it) {
Velocity *v = ecs_term(it, Velocity, 2);

/* Print the set of components for the iterated over entities */
char *type_str = ecs_type_str(it->world, it->type);
char *type_str = ecs_table_str(it->world, it->table);
printf("Move entities with [%s]\n", type_str);
ecs_os_free(type_str);

Expand Down
24 changes: 12 additions & 12 deletions examples/c/queries/change_tracking/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ int main(int argc, char *argv[]) {
// currently iterating has changed since last iteration.
// Because this is the first time the query is iterated, all tables
// will show up as changed.
char *type_str = ecs_type_str(world, it.type);
printf("it.changed for table [%s]: %d\n", type_str,
char *table_str = ecs_table_str(world, it.table);
printf("it.changed for table [%s]: %d\n", table_str,
ecs_query_changed(q_read, &it));
ecs_os_free(type_str);
ecs_os_free(table_str);
}

// Now that we have iterated all tables, the dirty state is reset.
Expand All @@ -102,17 +102,17 @@ int main(int argc, char *argv[]) {
while (ecs_query_next(&it)) {
Dirty *dirty = ecs_term(&it, Dirty, 1);

char *type_str = ecs_type_str(world, it.type);
printf("iterate table [%s]\n", type_str);
ecs_os_free(type_str);
char *table_str = ecs_table_str(world, it.table);
printf("iterate table [%s]\n", table_str);
ecs_os_free(table_str);

// Because we enforced that Dirty is a shared component, we can check
// a single value for the entire table.
if (!dirty->value) {
ecs_query_skip(&it);
type_str = ecs_type_str(world, it.type);
printf("it.skip for table [%s]\n", type_str);
ecs_os_free(type_str);
table_str = ecs_table_str(world, it.table);
printf("it.skip for table [%s]\n", table_str);
ecs_os_free(table_str);
continue;
}

Expand All @@ -131,10 +131,10 @@ int main(int argc, char *argv[]) {
// When we iterate the read query, we'll see that one table has changed.
it = ecs_query_iter(world, q_read);
while (ecs_query_next(&it)) {
char *type_str = ecs_type_str(world, it.type);
printf("it.changed for table [%s]: %d\n", type_str,
char *table_str = ecs_table_str(world, it.table);
printf("it.changed for table [%s]: %d\n", table_str,
ecs_query_changed(q_read, &it));
ecs_os_free(type_str);
ecs_os_free(table_str);
}

// Output:
Expand Down
Loading

0 comments on commit 90ad5f8

Please sign in to comment.