tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit b4f3df492a462e8f1a796080aa611232aa52b13d
parent ff6a6d24022bb152a7e59b6802cd45cbb3255029
Author: André Bargull <andre.bargull@gmail.com>
Date:   Fri, 12 Dec 2025 17:38:14 +0000

Bug 2005531 - Part 2: Move ensureLinear into caller. r=spidermonkey-reviewers,dminor

Align with other `SharedIntlData` methods which already expect a linear
string as their input.

Differential Revision: https://phabricator.services.mozilla.com/D276019

Diffstat:
Mjs/src/builtin/intl/Collator.cpp | 12++++++++++--
Mjs/src/builtin/intl/SharedIntlData.cpp | 29++++++++---------------------
Mjs/src/builtin/intl/SharedIntlData.h | 4++--
3 files changed, 20 insertions(+), 25 deletions(-)

diff --git a/js/src/builtin/intl/Collator.cpp b/js/src/builtin/intl/Collator.cpp @@ -471,7 +471,11 @@ bool js::intl_isUpperCaseFirst(JSContext* cx, unsigned argc, Value* vp) { SharedIntlData& sharedIntlData = cx->runtime()->sharedIntlData.ref(); - RootedString locale(cx, args[0].toString()); + Rooted<JSLinearString*> locale(cx, args[0].toString()->ensureLinear(cx)); + if (!locale) { + return false; + } + bool isUpperFirst; if (!sharedIntlData.isUpperCaseFirst(cx, locale, &isUpperFirst)) { return false; @@ -488,7 +492,11 @@ bool js::intl_isIgnorePunctuation(JSContext* cx, unsigned argc, Value* vp) { SharedIntlData& sharedIntlData = cx->runtime()->sharedIntlData.ref(); - RootedString locale(cx, args[0].toString()); + Rooted<JSLinearString*> locale(cx, args[0].toString()->ensureLinear(cx)); + if (!locale) { + return false; + } + bool isIgnorePunctuation; if (!sharedIntlData.isIgnorePunctuation(cx, locale, &isIgnorePunctuation)) { return false; diff --git a/js/src/builtin/intl/SharedIntlData.cpp b/js/src/builtin/intl/SharedIntlData.cpp @@ -725,7 +725,7 @@ bool js::intl::SharedIntlData::ensureUpperCaseFirstLocales(JSContext* cx) { #endif // DEBUG || MOZ_SYSTEM_ICU bool js::intl::SharedIntlData::isUpperCaseFirst(JSContext* cx, - HandleString locale, + Handle<JSLinearString*> locale, bool* isUpperFirst) { #if DEBUG || MOZ_SYSTEM_ICU if (!ensureUpperCaseFirstLocales(cx)) { @@ -733,23 +733,17 @@ bool js::intl::SharedIntlData::isUpperCaseFirst(JSContext* cx, } #endif - JSLinearString* localeLinear = locale->ensureLinear(cx); - if (!localeLinear) { - return false; - } - #if !MOZ_SYSTEM_ICU // "da" (Danish) and "mt" (Maltese) are the only two supported locales using // upper-case first. CLDR also lists "cu" (Church Slavic) as an upper-case // first locale, but since it's not supported in ICU, we don't care about it // here. - bool isDefaultUpperCaseFirstLocale = - js::StringEqualsLiteral(localeLinear, "da") || - js::StringEqualsLiteral(localeLinear, "mt"); + bool isDefaultUpperCaseFirstLocale = js::StringEqualsLiteral(locale, "da") || + js::StringEqualsLiteral(locale, "mt"); #endif #if DEBUG || MOZ_SYSTEM_ICU - LocaleHasher::Lookup lookup(localeLinear); + LocaleHasher::Lookup lookup(locale); *isUpperFirst = upperCaseFirstLocales.has(lookup); #else *isUpperFirst = isDefaultUpperCaseFirstLocale; @@ -815,29 +809,22 @@ bool js::intl::SharedIntlData::ensureIgnorePunctuationLocales(JSContext* cx) { } #endif // DEBUG || MOZ_SYSTEM_ICU -bool js::intl::SharedIntlData::isIgnorePunctuation(JSContext* cx, - HandleString locale, - bool* ignorePunctuation) { +bool js::intl::SharedIntlData::isIgnorePunctuation( + JSContext* cx, Handle<JSLinearString*> locale, bool* ignorePunctuation) { #if DEBUG || MOZ_SYSTEM_ICU if (!ensureIgnorePunctuationLocales(cx)) { return false; } #endif - JSLinearString* localeLinear = locale->ensureLinear(cx); - if (!localeLinear) { - return false; - } - #if !MOZ_SYSTEM_ICU // "th" (Thai) is the only supported locale which ignores punctuation by // default. - bool isDefaultIgnorePunctuationLocale = - js::StringEqualsLiteral(localeLinear, "th"); + bool isDefaultIgnorePunctuationLocale = js::StringEqualsLiteral(locale, "th"); #endif #if DEBUG || MOZ_SYSTEM_ICU - LocaleHasher::Lookup lookup(localeLinear); + LocaleHasher::Lookup lookup(locale); *ignorePunctuation = ignorePunctuationLocales.has(lookup); #else *ignorePunctuation = isDefaultIgnorePunctuationLocale; diff --git a/js/src/builtin/intl/SharedIntlData.h b/js/src/builtin/intl/SharedIntlData.h @@ -361,7 +361,7 @@ class SharedIntlData { * Sets |isUpperFirst| to true if |locale| sorts upper-case characters * before lower-case characters. */ - bool isUpperCaseFirst(JSContext* cx, JS::Handle<JSString*> locale, + bool isUpperCaseFirst(JSContext* cx, JS::Handle<JSLinearString*> locale, bool* isUpperFirst); private: @@ -380,7 +380,7 @@ class SharedIntlData { /** * Sets |ignorePunctuation| to true if |locale| ignores punctuation. */ - bool isIgnorePunctuation(JSContext* cx, JS::Handle<JSString*> locale, + bool isIgnorePunctuation(JSContext* cx, JS::Handle<JSLinearString*> locale, bool* ignorePunctuation); private: