Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cgen: use C99 short fixed array init syntax #20785

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

zeozeozeo
Copy link
Contributor

@zeozeozeo zeozeozeo commented Feb 11, 2024

Before this change, cgen would initialize fixed arrays like this:

Array_fixed_u8_5 buffer = {0, 0, 0, 0, 0};

This means that large arrays would generate a lot of C code just for initializing the array, and that significantly increased compilation times. C99 allows this short initialization syntax (see C99 6.7.8/21):

Array_fixed_u8_2048 buffer = {0}; // array of 2048 zeroes

Size of v.c before this change: 6,35 MB (6 665 526 bytes)
Size of v.c after this change: 6,11 MB (6 411 950 bytes) (-253 kb)

Before this commit, cgen would initialize fixed arrays like this:

```c
Array_fixed_u8_5 buffer = {0, 0, 0, 0, 0};
```

This means that large arrays would generate *a lot* of C code just for
initializing the array, and that significantly increased compilation
times. C99 allows this short initialization syntax (see C99 6.7.8/21):

```c
Array_fixed_u8_2048 buffer = {0}; // array of 2048 zeroes
```
@zeozeozeo zeozeozeo changed the title cgen: use C99 short fixed array init cgen: use C99 short fixed array init syntax Feb 11, 2024
@zeozeozeo zeozeozeo marked this pull request as draft February 11, 2024 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant