Closed Bug 1187145 Opened 9 years ago Closed 9 years ago

Replace nsBaseHashtable::Enumerate() calls in gfx/ with iterators

Categories

(Core :: Graphics, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla44
Tracking Status
firefox44 --- fixed

People

(Reporter: n.nethercote, Assigned: sotaro)

References

Details

(Whiteboard: [gfx-noted])

Attachments

(1 file, 4 obsolete files)

Because iterators are so much nicer than enumerate functions.

There are nine occurrences of Enumerate() in this directory.

A note to the assignee: to preserve existing behaviour, you should probably use
nsBaseHashtable::Iterator::Data() rather than nsBaseHashtable::Iterator::UserData(). (The latter should be used when replacing nsBaseHashtable::EnumerateRead()).
Assignee: nobody → sotaro.ikeda.g
Whiteboard: [gfx-noted]
Update nits.
Attachment #8661847 - Attachment is obsolete: true
Improved readability of types.
Attachment #8661867 - Attachment is obsolete: true
Attachment #8662051 - Flags: review?(jdaggett)
Comment on attachment 8662051 [details] [diff] [review]
patch - Replace nsBaseHashtable::Enumerate() calls in gfx/ with iterators

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

I have some drive-by comments...

::: gfx/thebes/gfxFT2FontList.cpp
@@ +1158,5 @@
>          // so we just maintain the existing order)
> +        for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
> +            nsStringHashKey::KeyType key = iter.Key();
> +            nsRefPtr<gfxFontFamily>& family = iter.Data();
> +            FinalizeFamilyMemberList(key, family, false /* aSortFaces */);

I usually write cases like this as "/* aSortFaces = */ false".

@@ +1331,5 @@
>  void
>  gfxFT2FontList::GetSystemFontList(InfallibleTArray<FontListEntry>* retValue)
>  {
> +    for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
> +        FT2FontFamily *family = static_cast<FT2FontFamily*>(iter.Data().get());

Put the '*' on the left? I know this file in inconsistent, but on-the-left is official Mozilla style so you might as well do it for changed code :)

Actually, you might as well use |auto| here instead. I think it's better when the type is obvious due to a static_cast.

@@ +1335,5 @@
> +        FT2FontFamily *family = static_cast<FT2FontFamily*>(iter.Data().get());
> +        family->AddFacesToFontList(retValue, FT2FontFamily::kVisible);
> +    }
> +    for (auto iter = mHiddenFontFamilies.Iter(); !iter.Done(); iter.Next()) {
> +        FT2FontFamily *family = static_cast<FT2FontFamily*>(iter.Data().get());

Ditto.

@@ +1477,5 @@
>      // hence @font-face { src:local(...) } will not find hidden fonts.
> +    for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
> +        nsStringHashKey::KeyType key = iter.Key();
> +        nsRefPtr<gfxFontFamily>& fontFamily = iter.Data();
> +        fontEntry = FindFullName(key, fontFamily, fullName);

I would inline FindFullName() here.

::: gfx/thebes/gfxPlatformFontList.cpp
@@ +283,5 @@
>      TimeStamp start = TimeStamp::Now();
> +    bool timedOut = false;
> +    // if mFirstChar is not 0, only load facenames for families
> +    // that start with this character
> +    char16_t firstChar(0);

|char16_t firstChar = 0;| looks better.
Attachment #8662051 - Flags: review?(jdaggett)
Thanks for the view, I''s update in a next patch.
Attachment #8665118 - Attachment is patch: true
Attachment #8665118 - Attachment mime type: text/x-patch → text/plain
Attachment #8665118 - Flags: review?(n.nethercote)
Comment on attachment 8665118 [details] [diff] [review]
patch - Replace nsBaseHashtable::Enumerate() calls in gfx/ with iterators

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

::: gfx/thebes/gfxFT2FontList.cpp
@@ +1460,5 @@
>  
>      // Note that we only check mFontFamilies here, not mHiddenFontFamilies;
>      // hence @font-face { src:local(...) } will not find hidden fonts.
> +    for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
> +        // Check family name, based on the assumption that the 

Nit: trailing whitespace.

@@ +1482,5 @@
> +                }
> +                if (fe->Name().Equals(fullName,
> +                                      nsCaseInsensitiveStringComparator())) {
> +                    fontEntry = static_cast<FT2FontEntry*>(fe);
> +                    break;

If you have a label at the end of the loop you could |goto| it from here...

@@ +1489,5 @@
> +        }
> +
> +        if (fontEntry) {
> +            break;
> +        }

... avoiding the need for this check.
Attachment #8665118 - Flags: review?(n.nethercote) → review+
Apply the comments.
Attachment #8665118 - Attachment is obsolete: true
Attachment #8665441 - Flags: review+
Thank you for doing this bug.
https://hg.mozilla.org/mozilla-central/rev/e2149155361c
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla44
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: