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

Remove locks in RadioButton and increase type safety (use generic types) #10251

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

h3xds1nz
Copy link
Contributor

@h3xds1nz h3xds1nz commented Jan 10, 2025

Description

Optimizes weird branching loops for cleanup, replace them with counting down loops instead.

  • Replace _groupNameToElements Hashtable with Dictionary<string, List<WeakReference<RadioButton>>>.
  • Use List<WeakReference<RadioButton>> instead of ArrayList to store weak references per group name.
  • Use WeakReference<RadioButton> instead of untyped WeakReference.
  • Initialize the List with at least 2 elements as we should expect more than 1 item per radio button group.
  • Renamed _groupNameToElements to t_groupNameToElements as its ThreadStatic variable.
  • I've also removed the locks on the collection as each Thread would gets its own copy anyways.
  • Also we no longer walk the visual tree unless it is actually needed.

Customer Impact

Increased performance, cleaner codebase for developers.

Regression

No.

Testing

Local build, extensive testing with radio buttons.

Risk

Low to medium, I believe I've tested most of the edge cases as I was working on something with the build.

Microsoft Reviewers: Open in CodeFlow

@h3xds1nz h3xds1nz requested review from a team as code owners January 10, 2025 01:21
@dotnet-policy-service dotnet-policy-service bot added PR metadata: Label to tag PRs, to facilitate with triage Community Contribution A label for all community Contributions labels Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community Contribution A label for all community Contributions PR metadata: Label to tag PRs, to facilitate with triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant