Replace embedded resource text files with inline data for Intl CLDR data#2343
Merged
Conversation
Convert 6 of 7 embedded .txt resource files in Jint/Native/Intl/Data/ to inline static readonly dictionary initializers in companion .Data.cs partial class files. This eliminates runtime text parsing, StreamReader allocations, and reflection-based GetManifestResourceStream calls for these data files. LikelySubtags.txt (133 KB) is kept as an embedded resource since inline dictionary entries would add ~217 KB to the DLL due to UTF-16 string encoding. Its loader is updated from the non-thread-safe ??= pattern to Lazy<T>. ComplexLanguageMapping and VariantMapping structs converted to readonly record structs with primary constructors. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
lahma
enabled auto-merge (squash)
March 22, 2026 08:08
This was referenced Mar 23, 2026
This was referenced Jun 8, 2026
This was referenced Jun 29, 2026
This was referenced Jul 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.txtresource files inJint/Native/Intl/Data/to inlinestatic readonlydictionary initializers in companion.Data.cspartial class filesStreamReaderallocations, and reflection-basedGetManifestResourceStreamcallsLikelySubtags.txt(133 KB) kept as embedded resource — inline would add ~217 KB to DLL due to UTF-16 string encoding; its loader fixed from non-thread-safe??=toLazy<T>ComplexLanguageMappingandVariantMappingconverted toreadonly record structwith primary constructorsBenchmark Results (BenchmarkDotNet, net10.0)
Before (embedded resources)
After (inline data)
Summary
Lazy<T>now for thread safety)Test plan
dotnet test Jint.Tests— 2764+2717 passed, 0 faileddotnet test Jint.Tests.Test262— 93,300 passed, 0 failed🤖 Generated with Claude Code