Skip to content

Conversation

@stephentoub
Copy link
Member

Avoids boxing keys/values, makes things more strongly typed, and reduces some ceremony.

Avoids boxing keys/values, makes things more strongly typed, and reduces some ceremony.
Copilot AI review requested due to automatic review settings January 6, 2026 15:09
@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Jan 6, 2026
@stephentoub stephentoub added area-System.Globalization and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Jan 6, 2026
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-globalization
See info in area-owners.md if you want to be subscribed.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR modernizes two classes in CoreLib by replacing legacy Hashtable collections with strongly-typed ConcurrentDictionary<TKey, TValue>, eliminating boxing/unboxing overhead and reducing code ceremony.

Key Changes

  • Replaced Hashtable.Synchronized() with ConcurrentDictionary for type safety and better performance
  • Simplified cache lookup patterns by using GetOrAdd() method instead of manual check-add-lock logic
  • Adopted modern C# syntax (collection expressions and expression-bodied members)

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/libraries/System.Private.CoreLib/src/System/Text/EncodingTable.cs Replaced Hashtable with ConcurrentDictionary<string, int> for encoding name-to-codepage mapping; simplified lookup logic using GetOrAdd
src/libraries/System.Private.CoreLib/src/System/CurrentSystemTimeZone.cs Replaced Hashtable with ConcurrentDictionary<int, DaylightTime> for year-to-daylight-changes caching; eliminated manual double-check locking pattern

Copy link
Member

@tarekgh tarekgh left a comment

Choose a reason for hiding this comment

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

Modulo copilot comments, LGTM!

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@tarekgh tarekgh added this to the 11.0.0 milestone Jan 6, 2026
@stephentoub stephentoub enabled auto-merge (squash) January 6, 2026 15:22
@stephentoub stephentoub merged commit b13fbd9 into dotnet:main Jan 6, 2026
139 of 143 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants