This fix targets at __CFLocaleGetDoesNotRequireSpecialCaseHandling. Currently, this function calls into class _NSSwiftLocale, then struct Locale, then any LocaleProtocol (LocaleICU here), which calls into a static func of struct Locale. All the hoop jumping contributes to a lot of retain and release calls.
It turns out that this function is only used by this one call site (_CFStrGetSpecialCaseHandlingLanguageIdentifierForLocale). This change simplifies the calling chain so that we call the static function directly from _NSSwiftLocale, and the result is cached inside this class directly.
I've verified that this change brings down the time spent in CFStringCompareWithOptionsAndLocale of the reproducable case in the radar down from 904ms to 397ms.
Also added a BenchmarkLocale target.
CFStringCompareWithOptionsAndLocale benchmark result before the change:
This fix targets at
__CFLocaleGetDoesNotRequireSpecialCaseHandling
. Currently, this function calls intoclass _NSSwiftLocale
, thenstruct Locale
, thenany LocaleProtocol
(LocaleICU
here), which calls into astatic func
ofstruct Locale
. All the hoop jumping contributes to a lot of retain and release calls.It turns out that this function is only used by this one call site (
_CFStrGetSpecialCaseHandlingLanguageIdentifierForLocale
). This change simplifies the calling chain so that we call the static function directly from_NSSwiftLocale
, and the result is cached inside this class directly.I've verified that this change brings down the time spent in
CFStringCompareWithOptionsAndLocale
of the reproducable case in the radar down from 904ms to 397ms.Also added a BenchmarkLocale target.
CFStringCompareWithOptionsAndLocale
benchmark result before the change:And after the change:
Resolves rdar://134912852