Skip to content

Conversation

@stephentoub
Copy link
Member

All the checks were already in place to lazy-initialize, and only a subset of cultures have date words.

All the checks were already in place to lazy-initialize, and only a subset of cultures have date words.
@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 updates DateTimeFormatInfoScanner to lazily initialize its internal date word collection, avoiding unnecessary allocations for cultures that have no date words, and cleans up documentation and implementation details.

Changes:

  • Remove the legacy banner comment and replace it with an XML <summary> comment describing DateTimeFormatInfoScanner and its role in DateTime.Parse.
  • Change m_dateWords from an eagerly initialized List<string> to a nullable List<string>? that is lazily initialized where needed, using collection expressions (m_dateWords ??= []).
  • Simplify GetDateWordsOfDTFI by using pattern matching on m_dateWords and List.ToArray() instead of manual array allocation and copying, and fix a spelling mistake in a comment (“Enumarate” → “Enumerate”).

@tarekgh tarekgh added this to the 11.0.0 milestone Feb 2, 2026
@stephentoub stephentoub enabled auto-merge (squash) February 2, 2026 19:05
@stephentoub stephentoub merged commit 71c7f67 into dotnet:main Feb 2, 2026
152 of 156 checks passed
@stephentoub stephentoub deleted the lazyinitscanner branch February 2, 2026 19:51
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.

3 participants