-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Sort complex forms alphabetically #1389
base: feat/1246-allow-reordering-complex-form-components
Are you sure you want to change the base?
Sort complex forms alphabetically #1389
Conversation
public async Task EnsureDefaultVernacularWritingSystemExistsInCrdt() | ||
{ | ||
// This is optionally called from tests that consume this fixture, so it could get called multiple times in parallel | ||
await _vernacularSemaphore.WaitAsync(100); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is doing what you expect. If there's already a writing system and no one has entered the semaphore, then it will enter immediately and then return without ever releasing it. The way it's written now all the code should be inside the try. If you don't start the try then the finally will never be called.
{ | ||
entry.Senses.ApplySortOrder(); | ||
entry.Components.ApplySortOrder(); | ||
entry.ComplexForms.Sort((a, b) => ComplexFormsComparison(a, b, sortCompareInfo)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a minor thing, but since ApplySortOrder
is getting called once for each entry I think it's worth trying to avoid an allocation here (due to capturing sortCompareInfo
in the callback). I would change the signature of ApplySortOrder
to take an IComparable<ComplexFormComponent>
, this basically lets you move the allocation outside of the for each entry loop. Basically you're encapsulating ComplexFormsComparison
into a class with a field to store CompareInfo
No description provided.