Skip to content

Commit e9bb107

Browse files
#1881 Don't call notify_on_add when creating entity in root table
1 parent d46dc36 commit e9bb107

File tree

2 files changed

+28
-26
lines changed

2 files changed

+28
-26
lines changed

distr/flecs.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8046,9 +8046,9 @@ void flecs_add_to_root_table(
80468046
ecs_assert(r != NULL, ECS_INTERNAL_ERROR, NULL);
80478047
ecs_assert(r->table == NULL, ECS_INTERNAL_ERROR, NULL);
80488048

8049-
ecs_table_diff_t diff = ECS_TABLE_DIFF_INIT;
8050-
flecs_new_entity(world, e, r, &world->store.root, &diff, false, 0);
8051-
ecs_assert(r->table == &world->store.root, ECS_INTERNAL_ERROR, NULL);
8049+
int32_t row = flecs_table_append(world, &world->store.root, e, false, false);
8050+
r->table = &world->store.root;
8051+
r->row = ECS_ROW_TO_RECORD(row, r->row & ECS_ROW_FLAGS_MASK);
80528052

80538053
flecs_journal(world, EcsJournalNew, e, 0, 0);
80548054
}
@@ -8513,16 +8513,16 @@ void flecs_deferred_add_remove(
85138513
const ecs_entity_desc_t *desc,
85148514
ecs_entity_t scope,
85158515
ecs_id_t with,
8516-
bool flecs_new_entity,
8516+
bool new_entity,
85178517
bool name_assigned)
85188518
{
85198519
const char *sep = desc->sep;
85208520
const char *root_sep = desc->root_sep;
85218521

85228522
/* If this is a new entity without a name, add the scope. If a name is
85238523
* provided, the scope will be added by the add_path_w_sep function */
8524-
if (flecs_new_entity) {
8525-
if (flecs_new_entity && scope && !name && !name_assigned) {
8524+
if (new_entity) {
8525+
if (new_entity && scope && !name && !name_assigned) {
85268526
ecs_add_id(world, entity, ecs_pair(EcsChildOf, scope));
85278527
}
85288528

@@ -8668,7 +8668,7 @@ ecs_entity_t ecs_entity_init(
86688668
}
86698669

86708670
const char *root_sep = desc->root_sep;
8671-
bool flecs_new_entity = false;
8671+
bool new_entity = false;
86728672
bool name_assigned = false;
86738673

86748674
/* Remove optional prefix from name. Entity names can be derived from
@@ -8716,7 +8716,7 @@ ecs_entity_t ecs_entity_init(
87168716
} else {
87178717
result = ecs_new(world);
87188718
}
8719-
flecs_new_entity = true;
8719+
new_entity = true;
87208720
ecs_assert(ecs_get_type(world, result) != NULL,
87218721
ECS_INTERNAL_ERROR, NULL);
87228722
ecs_assert(ecs_get_type(world, result)->count == 0,
@@ -8771,10 +8771,10 @@ ecs_entity_t ecs_entity_init(
87718771

87728772
if (ecs_is_deferred(world)) {
87738773
flecs_deferred_add_remove((ecs_world_t*)stage, result, name, desc,
8774-
scope, with, flecs_new_entity, name_assigned);
8774+
scope, with, new_entity, name_assigned);
87758775
} else {
87768776
if (flecs_traverse_add(world, result, name, desc,
8777-
scope, with, flecs_new_entity, name_assigned))
8777+
scope, with, new_entity, name_assigned))
87788778
{
87798779
return 0;
87808780
}
@@ -10365,9 +10365,10 @@ void ecs_make_alive(
1036510365
ecs_assert(r != NULL, ECS_INTERNAL_ERROR, NULL);
1036610366
ecs_assert(r->table == NULL, ECS_INTERNAL_ERROR, NULL);
1036710367

10368-
ecs_table_diff_t diff = ECS_TABLE_DIFF_INIT;
10369-
flecs_new_entity(world, entity, r, &world->store.root, &diff, false, 0);
10370-
ecs_assert(r->table == &world->store.root, ECS_INTERNAL_ERROR, NULL);
10368+
int32_t row = flecs_table_append(
10369+
world, &world->store.root, entity, false, false);
10370+
r->table = &world->store.root;
10371+
r->row = ECS_ROW_TO_RECORD(row, r->row & ECS_ROW_FLAGS_MASK);
1037110372
error:
1037210373
return;
1037310374
}

src/entity.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -674,9 +674,9 @@ void flecs_add_to_root_table(
674674
ecs_assert(r != NULL, ECS_INTERNAL_ERROR, NULL);
675675
ecs_assert(r->table == NULL, ECS_INTERNAL_ERROR, NULL);
676676

677-
ecs_table_diff_t diff = ECS_TABLE_DIFF_INIT;
678-
flecs_new_entity(world, e, r, &world->store.root, &diff, false, 0);
679-
ecs_assert(r->table == &world->store.root, ECS_INTERNAL_ERROR, NULL);
677+
int32_t row = flecs_table_append(world, &world->store.root, e, false, false);
678+
r->table = &world->store.root;
679+
r->row = ECS_ROW_TO_RECORD(row, r->row & ECS_ROW_FLAGS_MASK);
680680

681681
flecs_journal(world, EcsJournalNew, e, 0, 0);
682682
}
@@ -1141,16 +1141,16 @@ void flecs_deferred_add_remove(
11411141
const ecs_entity_desc_t *desc,
11421142
ecs_entity_t scope,
11431143
ecs_id_t with,
1144-
bool flecs_new_entity,
1144+
bool new_entity,
11451145
bool name_assigned)
11461146
{
11471147
const char *sep = desc->sep;
11481148
const char *root_sep = desc->root_sep;
11491149

11501150
/* If this is a new entity without a name, add the scope. If a name is
11511151
* provided, the scope will be added by the add_path_w_sep function */
1152-
if (flecs_new_entity) {
1153-
if (flecs_new_entity && scope && !name && !name_assigned) {
1152+
if (new_entity) {
1153+
if (new_entity && scope && !name && !name_assigned) {
11541154
ecs_add_id(world, entity, ecs_pair(EcsChildOf, scope));
11551155
}
11561156

@@ -1296,7 +1296,7 @@ ecs_entity_t ecs_entity_init(
12961296
}
12971297

12981298
const char *root_sep = desc->root_sep;
1299-
bool flecs_new_entity = false;
1299+
bool new_entity = false;
13001300
bool name_assigned = false;
13011301

13021302
/* Remove optional prefix from name. Entity names can be derived from
@@ -1344,7 +1344,7 @@ ecs_entity_t ecs_entity_init(
13441344
} else {
13451345
result = ecs_new(world);
13461346
}
1347-
flecs_new_entity = true;
1347+
new_entity = true;
13481348
ecs_assert(ecs_get_type(world, result) != NULL,
13491349
ECS_INTERNAL_ERROR, NULL);
13501350
ecs_assert(ecs_get_type(world, result)->count == 0,
@@ -1399,10 +1399,10 @@ ecs_entity_t ecs_entity_init(
13991399

14001400
if (ecs_is_deferred(world)) {
14011401
flecs_deferred_add_remove((ecs_world_t*)stage, result, name, desc,
1402-
scope, with, flecs_new_entity, name_assigned);
1402+
scope, with, new_entity, name_assigned);
14031403
} else {
14041404
if (flecs_traverse_add(world, result, name, desc,
1405-
scope, with, flecs_new_entity, name_assigned))
1405+
scope, with, new_entity, name_assigned))
14061406
{
14071407
return 0;
14081408
}
@@ -2993,9 +2993,10 @@ void ecs_make_alive(
29932993
ecs_assert(r != NULL, ECS_INTERNAL_ERROR, NULL);
29942994
ecs_assert(r->table == NULL, ECS_INTERNAL_ERROR, NULL);
29952995

2996-
ecs_table_diff_t diff = ECS_TABLE_DIFF_INIT;
2997-
flecs_new_entity(world, entity, r, &world->store.root, &diff, false, 0);
2998-
ecs_assert(r->table == &world->store.root, ECS_INTERNAL_ERROR, NULL);
2996+
int32_t row = flecs_table_append(
2997+
world, &world->store.root, entity, false, false);
2998+
r->table = &world->store.root;
2999+
r->row = ECS_ROW_TO_RECORD(row, r->row & ECS_ROW_FLAGS_MASK);
29993000
error:
30003001
return;
30013002
}

0 commit comments

Comments
 (0)