Repository: dotnet/runtime
File: src/libraries/System.Private.CoreLib/src/System/Globalization/CultureInfo.cs (C#)

Code before:
                Dictionary<string, CultureInfo>? cache = s_cachedCulturesByName;
                if (cache is null)
                {
                    cache = new Dictionary<string, CultureInfo>();
                    cache = Interlocked.CompareExchange(ref s_cachedCulturesByName, cache, null) ?? cache;
                }

                return cache;
            }
        }

        private static Dictionary<int, CultureInfo> CachedCulturesByLcid
        {
            get
            {
                Dictionary<int, CultureInfo>? cache = s_cachedCulturesByLcid;
                if (cache is null)
                {
                    cache = new Dictionary<int, CultureInfo>();
                    cache = Interlocked.CompareExchange(ref s_cachedCulturesByLcid, cache, null) ?? cache;
                }

                return cache;
            }
        }

        public static CultureInfo GetCultureInfoByIetfLanguageTag(string name)
        {
            // Disallow old zh-CHT/zh-CHS names
            if (name == "zh-CHT" || name == "zh-CHS")
            {
                throw new CultureNotFoundException(nameof(name), SR.Format(SR.Argument_CultureIetfNotSupported, name));
            }

            CultureInfo ci = GetCultureInfo(name);

            // Disallow alt sorts and es-es_TS
            if (ci.LCID > 0xffff || ci.LCID == 0x040a)
            {
                throw new CultureNotFoundException(nameof(name), SR.Format(SR.Argument_CultureIetfNotSupported, name));
            }

            return ci;
        }
    }
}


Review comment (refactor):
This PR’s title indicates it only simplifies CreateSpecificCulture, but this hunk also refactors GetCultureInfoByIetfLanguageTag. Consider dropping this unrelated change or updating the PR title/description to reflect both changes (helps keep CoreLib diffs focused).

Code after:
                }

                return cache;
            }
        }

        private static Dictionary<int, CultureInfo> CachedCulturesByLcid
        {
            get
            {
                Dictionary<int, CultureInfo>? cache = s_cachedCulturesByLcid;
                if (cache is null)
                {
                    cache = new Dictionary<int, CultureInfo>();
                    cache = Interlocked.CompareExchange(ref s_cachedCulturesByLcid, cache, null) ?? cache;
                }

                return cache;
            }
        }

        public static CultureInfo GetCultureInfoByIetfLanguageTag(string name)
        {
            // Disallow old zh-CHT/zh-CHS names
            if (name is "zh-CHT" or "zh-CHS")
            {
                throw new CultureNotFoundException(nameof(name), SR.Format(SR.Argument_CultureIetfNotSupported, name));
            }

            CultureInfo ci = GetCultureInfo(name);

            // Disallow alt sorts and es-es_TS
            if (ci.LCID > 0xffff || ci.LCID == 0x040a)
            {
                throw new CultureNotFoundException(nameof(name), SR.Format(SR.Argument_CultureIetfNotSupported, name));
            }

            return ci;
        }
    }
}