Skip to content

[stdlib] Use const for graphemeBreakProperties #40711

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

Closed

Conversation

benrimmington
Copy link
Contributor

No description provided.

@benrimmington benrimmington requested a review from Azoy December 28, 2021 09:48

static __swift_uint32_t _swift_stdlib_graphemeBreakProperties[621] = {
static const __swift_uint32_t _swift_stdlib_graphemeBreakProperties[610] = {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only change I wanted to make (adding the const keyword) but the gen-unicode-data package seems outdated — I had to rename input/output paths, etc. (And the generated data is different.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't say GRAPHEME_BREAK_DATA_COUNT there, I take it, instead of repeating the magic number?

Copy link
Contributor Author

@benrimmington benrimmington Dec 31, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't say GRAPHEME_BREAK_DATA_COUNT there, I take it, instead of repeating the magic number?

If the array is declared with a size, but its initializer list contains fewer elements, the rest will be zero initialized.

So the safest way might be to declare it with empty [] brackets, and then static_assert with the expected size and the sizeof operator (or the std::extent value).

(But this is probably unnecessary for auto-generated declarations.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh it seems I forgot to push my changes to this target. If you want, I can push those so that this is just the const addition?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want, I can push those so that this is just the const addition?

It might be easier if you add the const keyword yourself, when pushing those changes. If so, this PR can be closed.

@benrimmington
Copy link
Contributor Author

Closing due to #40746.

@benrimmington benrimmington deleted the const-grapheme-break branch January 14, 2022 18:59
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.

3 participants