Skip to content

Evolve CollationSpecialPrimariesV1 data struct#7872

Open
robertbastian wants to merge 4 commits intounicode-org:mainfrom
robertbastian:primaries
Open

Evolve CollationSpecialPrimariesV1 data struct#7872
robertbastian wants to merge 4 commits intounicode-org:mainfrom
robertbastian:primaries

Conversation

@robertbastian
Copy link
Copy Markdown
Member

Now that we can change the baked representation, this evolves the data struct while keeping the serialized representation stable, removing the hacks we had added for this.

Changelog

icu_collator: Changes to the CollationSpecialPrimariesV1 data struct

Copy link
Copy Markdown
Member

@sffc sffc left a comment

Choose a reason for hiding this comment

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

I like how the code is structured better with this PR.

Comment thread components/collator/src/comparison.rs Outdated
let jamo = jamo.unwrap();

impl<'a> CollatorBorrowed<'a> {
fn collation_elements<C: Iterator<Item = char>>(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Did you re-run benchmarks to see that this doesn't regress perfomance? From the code change, it looks like it shouldn't, but there have been surprises here previously.

Copy link
Copy Markdown
Member

@hsivonen hsivonen Apr 15, 2026

Choose a reason for hiding this comment

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

Specifically, we need to make sure that rustc keeps initializing CollationElementsdirectly into its eventual memory location instead of initializing it first and then moving it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Well, the ::new call is a way more complex function than this, so if anything doesn't get inlined it's that (and that's preexisting). But I can run benchmarks to confirm, is it just cargo bench?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

cargo criterion, rather, with measures to make the clock stable (CPU governor set to performance and Intel turbo or AMD boost turned off). I even do setarch -R cargo criterion just in case, but I'm not sure if that bit matters.

(And, yes, it looks OK, but there's previously been a regression here that looked OK from source.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

ok I've inlined this instead. this is now code-equivalent to the previous macro version, with the upside that we have types and stuff

@robertbastian robertbastian requested a review from hsivonen April 15, 2026 15:16
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