Skip to content

Commit 362e2f6

Browse files
#1569 Remove redundant block_tail member from block allocator
1 parent 8e15d0e commit 362e2f6

File tree

4 files changed

+12
-22
lines changed

4 files changed

+12
-22
lines changed

distr/flecs.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28573,17 +28573,14 @@ ecs_block_allocator_chunk_header_t* flecs_balloc_block(
2857328573
ECS_SIZEOF(ecs_block_allocator_block_t));
2857428574

2857528575
block->memory = first_chunk;
28576-
if (!allocator->block_tail) {
28577-
ecs_assert(!allocator->block_head, ECS_INTERNAL_ERROR, 0);
28578-
block->next = NULL;
28579-
allocator->block_head = block;
28580-
allocator->block_tail = block;
28581-
} else {
28582-
block->next = NULL;
28583-
allocator->block_tail->next = block;
28584-
allocator->block_tail = block;
28576+
block->next = NULL;
28577+
28578+
if (allocator->block_head) {
28579+
block->next = allocator->block_head;
2858528580
}
2858628581

28582+
allocator->block_head = block;
28583+
2858728584
ecs_block_allocator_chunk_header_t *chunk = first_chunk;
2858828585
int32_t i, end;
2858928586
for (i = 0, end = allocator->chunks_per_block - 1; i < end; ++i) {
@@ -28619,7 +28616,6 @@ void flecs_ballocator_init(
2861928616
ba->block_size = ba->chunks_per_block * ba->chunk_size;
2862028617
ba->head = NULL;
2862128618
ba->block_head = NULL;
28622-
ba->block_tail = NULL;
2862328619
}
2862428620

2862528621
ecs_block_allocator_t* flecs_ballocator_new(

distr/flecs.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1554,7 +1554,6 @@ typedef struct ecs_block_allocator_chunk_header_t {
15541554
typedef struct ecs_block_allocator_t {
15551555
ecs_block_allocator_chunk_header_t *head;
15561556
ecs_block_allocator_block_t *block_head;
1557-
ecs_block_allocator_block_t *block_tail;
15581557
int32_t chunk_size;
15591558
int32_t data_size;
15601559
int32_t chunks_per_block;

include/flecs/datastructures/block_allocator.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ typedef struct ecs_block_allocator_chunk_header_t {
2222
typedef struct ecs_block_allocator_t {
2323
ecs_block_allocator_chunk_header_t *head;
2424
ecs_block_allocator_block_t *block_head;
25-
ecs_block_allocator_block_t *block_tail;
2625
int32_t chunk_size;
2726
int32_t data_size;
2827
int32_t chunks_per_block;

src/datastructures/block_allocator.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,14 @@ ecs_block_allocator_chunk_header_t* flecs_balloc_block(
3232
ECS_SIZEOF(ecs_block_allocator_block_t));
3333

3434
block->memory = first_chunk;
35-
if (!allocator->block_tail) {
36-
ecs_assert(!allocator->block_head, ECS_INTERNAL_ERROR, 0);
37-
block->next = NULL;
38-
allocator->block_head = block;
39-
allocator->block_tail = block;
40-
} else {
41-
block->next = NULL;
42-
allocator->block_tail->next = block;
43-
allocator->block_tail = block;
35+
block->next = NULL;
36+
37+
if (allocator->block_head) {
38+
block->next = allocator->block_head;
4439
}
4540

41+
allocator->block_head = block;
42+
4643
ecs_block_allocator_chunk_header_t *chunk = first_chunk;
4744
int32_t i, end;
4845
for (i = 0, end = allocator->chunks_per_block - 1; i < end; ++i) {
@@ -78,7 +75,6 @@ void flecs_ballocator_init(
7875
ba->block_size = ba->chunks_per_block * ba->chunk_size;
7976
ba->head = NULL;
8077
ba->block_head = NULL;
81-
ba->block_tail = NULL;
8278
}
8379

8480
ecs_block_allocator_t* flecs_ballocator_new(

0 commit comments

Comments
 (0)