Skip to content

Commit 8a2db98

Browse files
committed
Simplify batching code that sets bits in the set_mask
1 parent 7ce74f4 commit 8a2db98

File tree

3 files changed

+8
-18
lines changed

3 files changed

+8
-18
lines changed

distr/flecs.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9393,9 +9393,9 @@ void flecs_cmd_batch_for_entity(
93939393
}
93949394
}
93959395

9396-
int32_t index = (i >= 64) + (i >= 128) + (i >= 192);
9397-
int32_t shift = i - 64 * index;
9398-
set_mask[index] |= (1llu << shift);
9396+
ecs_assert(i < 256, ECS_UNSUPPORTED,
9397+
"cannot add more than 256 components in a single operation");
9398+
set_mask[i >> 6] |= 1llu << (i & 63);
93999399

94009400
world->info.cmd.batched_command_count ++;
94019401
break;
@@ -13395,12 +13395,7 @@ void flecs_emit(
1339513395
if (set_mask && event == EcsOnAdd) {
1339613396
ecs_assert(i < 256, ECS_UNSUPPORTED,
1339713397
"cannot add more than 256 components in a single operation");
13398-
13399-
int32_t index = (i >= 64) + (i >= 128) + (i >= 192);
13400-
int32_t shift = i - 64 * index;
13401-
13402-
ecs_flags64_t id_bit = 1llu << shift;
13403-
if (id_bit & set_mask[index]) {
13398+
if (set_mask[i >> 6] & (1llu << (i & 63))) {
1340413399
/* Component is already set, so don't override with prefab value */
1340513400
id_can_override = false;
1340613401
}

src/entity.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4907,9 +4907,9 @@ void flecs_cmd_batch_for_entity(
49074907
}
49084908
}
49094909

4910-
int32_t index = (i >= 64) + (i >= 128) + (i >= 192);
4911-
int32_t shift = i - 64 * index;
4912-
set_mask[index] |= (1llu << shift);
4910+
ecs_assert(i < 256, ECS_UNSUPPORTED,
4911+
"cannot add more than 256 components in a single operation");
4912+
set_mask[i >> 6] |= 1llu << (i & 63);
49134913

49144914
world->info.cmd.batched_command_count ++;
49154915
break;

src/observable.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,12 +1273,7 @@ void flecs_emit(
12731273
if (set_mask && event == EcsOnAdd) {
12741274
ecs_assert(i < 256, ECS_UNSUPPORTED,
12751275
"cannot add more than 256 components in a single operation");
1276-
1277-
int32_t index = (i >= 64) + (i >= 128) + (i >= 192);
1278-
int32_t shift = i - 64 * index;
1279-
1280-
ecs_flags64_t id_bit = 1llu << shift;
1281-
if (id_bit & set_mask[index]) {
1276+
if (set_mask[i >> 6] & (1llu << (i & 63))) {
12821277
/* Component is already set, so don't override with prefab value */
12831278
id_can_override = false;
12841279
}

0 commit comments

Comments
 (0)