Skip to content

Memoize the IANA timezone identifiers lookup. - #25

Merged
gustavofreze merged 2 commits into
mainfrom
refactor/memoize-timezone-identifiers
Nov 2, 2026
Merged

gustavofreze merged 2 commits into
mainfrom
refactor/memoize-timezone-identifiers

Conversation

@gustavofreze

Copy link
Copy Markdown
Member

Please follow the contributing guidelines.

Summary

  • Builds the IANA timezone identifier lookup once per process (Internal/TimezoneDatabase) instead of calling DateTimeZone::listIdentifiers() on every Timezone construction, and Timezone asks it whether the identifier is omitted.
  • Accepts exactly the same identifiers and raises the same InvalidTimezone as before. No public signature changes.
  • Timezone::from() drops from about 65 µs to 0.5 µs, Instant::fromString from about 75 µs to 9 µs and Instant::plus from about 150 µs to 10 µs. A consumer computing free slots over a 29-day window goes from 12.4 s to 0.8 s.

Related issue

None.

Checklist

  • Tests added or updated.
  • Documentation updated when applicable.
  • make review passes.
  • make tests passes.

@gustavofreze
gustavofreze merged commit 283fc15 into main Nov 2, 2026
4 checks passed
@gustavofreze
gustavofreze deleted the refactor/memoize-timezone-identifiers branch November 2, 2026 18:35
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.

1 participant