Closed Bug 1214169 Opened 9 years ago Closed 8 years ago

Always use ICU in nsCollationMacUC

Categories

(Core :: Internationalization, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla46
Tracking Status
firefox46 --- fixed

People

(Reporter: hsivonen, Assigned: gordonsu14)

References

Details

(Whiteboard: [good first bug][lang=c++])

Attachments

(2 files, 3 obsolete files)

Keeping the non-ICU code paths in nsCollationMacUC makes no sense. We should remove the non-ICU code paths. (Once that's done, we should use the ICU-based code on other platforms, too.)

Basically, we should assume that mUseICU is always true and remove dead code accordingly.
Attached patch nsCollationMacUC.cpp (obsolete) — Splinter Review
My attempt at addressing Bug 1214169. This is my first bug patch, so if I forgot anything, please tell me. Also removed mUseICU from nsCollationMacUC.h.

Removed all instances of mUseICU, and dead code using it.
Attachment #8674048 - Flags: review?(hsivonen)
Comment on attachment 8674048 [details] [diff] [review]
nsCollationMacUC.cpp

Looks good to me. Thank you!

However, I'm not the module owner or peer, so my review isn't sufficient to land this. Also, we generally attach patches generated with |hg export|. I'll attach the changes in a patch form and request review from a module peer in a moment.
Attachment #8674048 - Flags: review?(hsivonen) → feedback+
Assignee: nobody → gordonsu14
Comment on attachment 8676092 [details] [diff] [review]
Remove the non-ICU code path

Oh, this is still lacking the .h changes.

Gordon, could you, please, post a patch that includes the .h changes (removing mUseICU as well as mCollator, the Carbon header include and the dead-code constants kCollationValueSizeFactor and kCacheSize)?
Attachment #8676092 - Flags: review?(VYV03354)
Attachment #8678708 - Flags: review?(VYV03354)
Comment on attachment 8678708 [details] [diff] [review]
Always use ICU in nsCollationMacUC

Review of attachment 8678708 [details] [diff] [review]:
-----------------------------------------------------------------

Please attach a new patch with the comments addressed and request a review again.

::: intl/locale/mac/nsCollationMacUC.cpp
@@ -24,3 @@
>    , mBuffer(nullptr)
>    , mBufferLen(1)
> -  , mUseICU(true)

You can also remove mLocale, mBuffer and mBufferLen because they are used only in the non-ICU code path.

@@ -26,5 @@
> -  , mUseICU(true)
> -{
> -  nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
> -  if (prefs) {
> -    prefs->GetBoolPref("intl.collation.mac.use_icu", &mUseICU);

Please also remove the "intl.collation.mac.use_icu" pref from modules/libpref/init/all.js and rewrite intl/locale/tests/unit/test_collation_mac_icu.js to remove dependency on the pref.

@@ -178,5 @@
> -    NS_ENSURE_TRUE(U_SUCCESS(status), NS_ERROR_FAILURE);
> -  } else {
> -    OSStatus err;
> -    UCCollateOptions newOptions;
> -    res = StrengthToOptions(newStrength, &newOptions);

Please remove the definition of StrengthToOptions. It is not used in the ICU code path.

@@ -225,5 @@
>  
> -  if (mUseICU) {
> -    rv = ConvertLocaleICU(locale, &mLocaleICU);
> -  } else {
> -    rv = ConvertLocale(locale, &mLocale);

Likewise, remove ConvertLocale.

@@ -327,4 @@
>        case UCOL_LESS: res = -1; break;
>        case UCOL_EQUAL: res = 0; break;
>        case UCOL_GREATER: res = 1; break;
>        default: MOZ_CRASH("ucol_strcoll returned bad UCollationResult");

nit: please fix the indent.
Attachment #8678708 - Flags: review?(VYV03354) → feedback+
Attachment #8678708 - Attachment is obsolete: true
Attachment #8681643 - Flags: review?(VYV03354)
Comment on attachment 8681643 [details] [diff] [review]
Always use ICU in nsCollationMacUC. r= Masatoshi Kimura

Review of attachment 8681643 [details] [diff] [review]:
-----------------------------------------------------------------

::: intl/locale/mac/nsCollationMacUC.cpp
@@ +210,5 @@
> +                          (const UChar*)PromiseFlatString(string1).get(), string1.Length(),
> +                          (const UChar*)PromiseFlatString(string2).get(), string2.Length());
> +  int32_t res;
> +  switch (uresult) {
> +      case UCOL_LESS:

I meant to say, please change the 4 indent to 2.
Attachment #8681643 - Flags: review?(VYV03354) → review+
Blocks: 943287
https://hg.mozilla.org/mozilla-central/rev/b5dcc2d9ccd7
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla46
You need to log in before you can comment on or make changes to this bug.