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

Sort complex forms alphabetically #1389

Draft
wants to merge 2 commits into
base: feat/1246-allow-reordering-complex-form-components
Choose a base branch
from

Conversation

myieye
Copy link
Contributor

@myieye myieye commented Jan 17, 2025

No description provided.

Copy link

UI unit Tests

12 tests  ±0   12 ✅ ±0   0s ⏱️ ±0s
 4 suites ±0    0 💤 ±0 
 1 files   ±0    0 ❌ ±0 

Results for commit 5802dd0. ± Comparison against base commit 0a5c35c.

Copy link

C# Unit Tests

104 tests  ±0   104 ✅ ±0   5s ⏱️ ±0s
 16 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 5802dd0. ± Comparison against base commit 0a5c35c.

@myieye myieye changed the base branch from develop to feat/1246-allow-reordering-complex-form-components January 17, 2025 12:16
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);
Copy link
Collaborator

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));
Copy link
Collaborator

@hahn-kev hahn-kev Jan 20, 2025

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

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.

2 participants