Closed
Bug 1182963
Opened 10 years ago
Closed 10 years ago
Use nsTHashTable::Iterator in layout/base/
Categories
(Core :: Layout, defect)
Core
Layout
Tracking
()
RESOLVED
FIXED
mozilla42
Tracking | Status | |
---|---|---|
firefox42 | --- | fixed |
People
(Reporter: n.nethercote, Assigned: TYLin)
References
Details
Attachments
(7 files, 8 obsolete files)
1.75 KB,
patch
|
n.nethercote
:
review+
|
Details | Diff | Splinter Review |
7.06 KB,
patch
|
n.nethercote
:
review+
|
Details | Diff | Splinter Review |
2.02 KB,
patch
|
TYLin
:
review+
|
Details | Diff | Splinter Review |
17.84 KB,
patch
|
TYLin
:
review+
|
Details | Diff | Splinter Review |
6.39 KB,
patch
|
TYLin
:
review+
|
Details | Diff | Splinter Review |
5.74 KB,
patch
|
TYLin
:
review+
|
Details | Diff | Splinter Review |
6.93 KB,
patch
|
TYLin
:
review+
|
Details | Diff | Splinter Review |
Because iterators are so much nicer than enumerate functions.
There are 21 occurrences of EnumerateEntries() in layout/base/ to be dealt with.
Assignee | ||
Updated•10 years ago
|
Assignee: nobody → tlin
Assignee | ||
Comment 1•10 years ago
|
||
Attachment #8632829 -
Flags: review?(roc)
Attachment #8632829 -
Flags: review?(n.nethercote)
Assignee | ||
Comment 2•10 years ago
|
||
Attachment #8632831 -
Flags: review?(n.nethercote)
Assignee | ||
Comment 3•10 years ago
|
||
Attachment #8632833 -
Flags: review?(n.nethercote)
Assignee | ||
Comment 4•10 years ago
|
||
Attachment #8632834 -
Flags: review?(n.nethercote)
Assignee | ||
Comment 5•10 years ago
|
||
Attachment #8632835 -
Flags: review?(n.nethercote)
Attachment #8632829 -
Flags: review?(roc) → review+
Reporter | ||
Updated•10 years ago
|
Attachment #8632831 -
Flags: review?(n.nethercote) → review+
Reporter | ||
Updated•10 years ago
|
Attachment #8632833 -
Flags: review?(n.nethercote) → review+
Reporter | ||
Comment 6•10 years ago
|
||
Comment on attachment 8632829 [details] [diff] [review]
Use nsTHashTable::Iterator in FrameLayerBuilder. (v1)
Review of attachment 8632829 [details] [diff] [review]:
-----------------------------------------------------------------
Thank you for working on this bug!
One of the good things about converting from enumeration to iteration is that you can put the iterator loop right where you need it, not in a separate function. This saves having to declare the functions, and pass arguments, and it's generally easier to read that way. Sometimes you can't do that, e.g. because the same enumeration/iteration occurs in two different places, or you have issues with access to private members across classes. But I don't think any of those are relevant here.
So I'd like to you get rid of DumpDisplayItemDataForFrame, ProcessRemovedDisplayItems, RestoreDisplayItemData, and RestorePaintedLayerItemEntries by inlining them to their individual call sites. This will reduce the code size further and make it easier to read. I will re-review once you do that. Thank you.
::: layout/base/FrameLayerBuilder.cpp
@@ +1721,3 @@
> }
> +
> + ComputeGeometryChangeForItem(data);
Please remove the |continue| and put the ComputeGeometryChangeForItem() call in an |else| block. That control flow is easier to understand.
@@ +1734,3 @@
>
> + nsAutoCString prefix;
> + prefix += aPrefix
You're missing a semicolon here. Have you compiled this patch?
Attachment #8632829 -
Flags: review?(n.nethercote) → feedback+
Reporter | ||
Comment 7•10 years ago
|
||
Comment on attachment 8632834 [details] [diff] [review]
Use nsTHashTable::Iterator in nsPresArena. (v1)
Review of attachment 8632834 [details] [diff] [review]:
-----------------------------------------------------------------
Again, I think inlining the iterator loops directly would make the code shorter and easier to read. And it will allow to you remove EnumerateData.
Attachment #8632834 -
Flags: review?(n.nethercote) → feedback+
Reporter | ||
Comment 8•10 years ago
|
||
Comment on attachment 8632835 [details] [diff] [review]
Use nsTHashTable::Iterator in nsRefreshDriver. (v1)
Review of attachment 8632835 [details] [diff] [review]:
-----------------------------------------------------------------
::: layout/base/nsRefreshDriver.cpp
@@ +1894,5 @@
> // the nearest multiple of the delay and move all the images in this table
> // to the main requests table.
> if (prevMultiple != static_cast<uint32_t>(curr.ToMilliseconds()) / aDelay) {
> parms->mDesired = start + TimeDuration::FromMilliseconds(prevMultiple * aDelay);
> + BeginRefreshingImages(aData->mEntries, parms);
This is a good example where the iterator loop has to be in its own function, because it's used in more than one place.
Attachment #8632835 -
Flags: review?(n.nethercote) → review+
Assignee | ||
Comment 9•10 years ago
|
||
(In reply to Nicholas Nethercote [:njn] from comment #6)
> So I'd like to you get rid of DumpDisplayItemDataForFrame,
> ProcessRemovedDisplayItems, RestoreDisplayItemData, and
> RestorePaintedLayerItemEntries by inlining them to their individual call
> sites. This will reduce the code size further and make it easier to read. I
> will re-review once you do that. Thank you.
I'll inline those functions in the next patch.
>
> @@ +1734,3 @@
> >
> > + nsAutoCString prefix;
> > + prefix += aPrefix
>
> You're missing a semicolon here. Have you compiled this patch?
Ouch. I should #define DEBUG_DISPLAY_ITEM_DATA and build again.
Assignee | ||
Comment 10•10 years ago
|
||
Inline DumpDisplayItemDataForFrame, ProcessRemovedDisplayItems,
RestoreDisplayItemData, and RestorePaintedLayerItemEntries.
Attachment #8632829 -
Attachment is obsolete: true
Attachment #8633536 -
Flags: review?(n.nethercote)
Assignee | ||
Comment 11•10 years ago
|
||
Rebase due to bug 1182744
Attachment #8632833 -
Attachment is obsolete: true
Attachment #8633539 -
Flags: review+
Assignee | ||
Comment 12•10 years ago
|
||
Inline UnpoisonFreeList and FreeListEnumerator.
Attachment #8632834 -
Attachment is obsolete: true
Attachment #8633541 -
Flags: review?(n.nethercote)
Assignee | ||
Comment 13•10 years ago
|
||
Attachment #8633542 -
Flags: review?(n.nethercote)
Assignee | ||
Comment 14•10 years ago
|
||
Attachment #8633543 -
Flags: review?(n.nethercote)
Assignee | ||
Comment 15•10 years ago
|
||
Attachment #8633543 -
Attachment is obsolete: true
Attachment #8633543 -
Flags: review?(n.nethercote)
Attachment #8633553 -
Flags: review?(n.nethercote)
Assignee | ||
Comment 16•10 years ago
|
||
Reporter | ||
Comment 17•10 years ago
|
||
Comment on attachment 8633536 [details] [diff] [review]
Use nsTHashTable::Iterator in FrameLayerBuilder. (v2)
Review of attachment 8633536 [details] [diff] [review]:
-----------------------------------------------------------------
::: layout/base/FrameLayerBuilder.cpp
@@ +203,5 @@
>
> /**
> * This is the userdata we associate with a layer manager.
> */
> +extern uint8_t gLayerManagerUserData;
This surprised me; it took me a minute to work out that you're effectively just forward declaring it. Seeing |extern| for a variable that's not shared between modules is odd. Maybe just move the definitions of gLayerManagerUserData (and perhaps the similar other constants) forward instead?
@@ +234,5 @@
> +
> + const char* layerState;
> + switch (data->mLayerState) {
> + case LAYER_NONE:
> + layerState = "LAYER_NONE"; break;
Nit: the |case| labels should be indented too :/ So says https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Coding_Style
@@ +5098,5 @@
> + }
> +
> + for (uint32_t i = 0; i < entry->mItems.Length(); i++) {
> + if (entry->mItems[i].mContainerLayerGeneration >= mContainerLayerGeneration) {
> + entry->mItems.TruncateLength(i);
This one is tricky! The original code returned PL_DHASH_NEXT here, thus exiting this for-loop early. Your new code doesn't do that. So you should |break| out of this loop after calling TruncateLength().
Actually... because entry->mItems has been truncated I guess the loop condition will fail the next time around. But that's rather subtle, and if somebody hoisted the entry->mItems.Length() into a local variable and then used that variable in the loop condition it would change the meaning. So I think adding the |break| is still a good idea because it makes things more obvious.
Attachment #8633536 -
Flags: review?(n.nethercote) → review+
Reporter | ||
Comment 18•10 years ago
|
||
Comment on attachment 8633541 [details] [diff] [review]
Use nsTHashTable::Iterator in nsPresArena. (v2)
Review of attachment 8633541 [details] [diff] [review]:
-----------------------------------------------------------------
::: layout/base/nsPresArena.cpp
@@ +156,5 @@
> + size_t* p;
> +
> + switch (NS_PTR_TO_INT32(entry->mKey)) {
> +#define FRAME_ID(classname) \
> + case nsQueryFrame::classname##_id: \
Again, |case|s should be indented.
@@ +184,5 @@
> + *p += totalSize;
> + totalSizeInFreeLists += totalSize;
> + }
> +
> + aArenaStats->mOther += (mallocSize - totalSizeInFreeLists);
Nit: the parentheses are unnecessary.
Attachment #8633541 -
Flags: review?(n.nethercote) → review+
Reporter | ||
Comment 19•10 years ago
|
||
Comment on attachment 8633542 [details] [diff] [review]
Use nsTHashTable::Iterator in nsPresShell. (v1)
Review of attachment 8633542 [details] [diff] [review]:
-----------------------------------------------------------------
::: layout/base/nsPresShell.cpp
@@ +9056,5 @@
> + for (auto iter = mFramesToDirty.Iter(); !iter.Done(); iter.Next()) {
> + // Mark frames dirty until target frame.
> + nsPtrHashKey<nsIFrame>* p = iter.Get();
> + for (nsIFrame* f = p->GetKey(); f && !NS_SUBTREE_DIRTY(f);
> + f = f->GetParent()) {
Nit: if a for loop header doesn't fit on one line, it's best to break it over three:
> for (nsIFrame* f = p->GetKey();
> f && !NS_SUBTREE_DIRTY(f);
> f = f->GetParent()) {
Attachment #8633542 -
Flags: review?(n.nethercote) → review+
Reporter | ||
Comment 20•10 years ago
|
||
Comment on attachment 8633553 [details] [diff] [review]
Use nsTHashTable::Iterator in nsPresContext. (v2)
Review of attachment 8633553 [details] [diff] [review]:
-----------------------------------------------------------------
::: layout/base/nsPresContext.cpp
@@ +3014,5 @@
> {
> + for (auto iter = aPlugins.Iter(); !iter.Done(); iter.Next()) {
> + auto f = static_cast<nsPluginFrame*>(iter.Get()->GetKey()->GetPrimaryFrame());
> + if (!f) {
> + NS_WARNING("Null frame in PluginsGeometryUpdate");
s/PluginsGeometryUpdate/PluginGetGeometryUpdate/
Attachment #8633553 -
Flags: review?(n.nethercote) → review+
Reporter | ||
Comment 21•10 years ago
|
||
Thank you for the patches.
Assignee | ||
Comment 22•10 years ago
|
||
Addressed comment #17:
* Move gPaintedDisplayItemLayerUserData, gColorLayerUserData, etc. to the
front of the file since LayerManagerData::Dump() references to one of them.
* Indent |case| labels.
* Add |break| after calling TruncateLength().
Attachment #8633536 -
Attachment is obsolete: true
Attachment #8633883 -
Flags: review+
Assignee | ||
Comment 23•10 years ago
|
||
Addressed comment #18.
* Indent |case| labels.
* Remove parentheses after +=
Attachment #8633541 -
Attachment is obsolete: true
Attachment #8633884 -
Flags: review+
Assignee | ||
Comment 24•10 years ago
|
||
Addressed comment #19:
* Break the long for-loop into three lines.
Attachment #8633542 -
Attachment is obsolete: true
Attachment #8633886 -
Flags: review+
Assignee | ||
Comment 25•10 years ago
|
||
Addressed comment #20:
* s/PluginsGeometryUpdate/PluginGetGeometryUpdate/
Attachment #8633553 -
Attachment is obsolete: true
Attachment #8633887 -
Flags: review+
Assignee | ||
Comment 26•10 years ago
|
||
Nicholas,
Thank you for reviewing my patches. Your comments are very helpful :)
Comment 27•10 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/34bfaa0e81d6
https://hg.mozilla.org/integration/mozilla-inbound/rev/13d5c3d8982a
https://hg.mozilla.org/integration/mozilla-inbound/rev/56c962946e5e
https://hg.mozilla.org/integration/mozilla-inbound/rev/8b4a52bd7393
https://hg.mozilla.org/integration/mozilla-inbound/rev/15077ee67520
https://hg.mozilla.org/integration/mozilla-inbound/rev/60070da355a6
https://hg.mozilla.org/integration/mozilla-inbound/rev/900d0863e9a4
Comment 28•10 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/34bfaa0e81d6
https://hg.mozilla.org/mozilla-central/rev/13d5c3d8982a
https://hg.mozilla.org/mozilla-central/rev/56c962946e5e
https://hg.mozilla.org/mozilla-central/rev/8b4a52bd7393
https://hg.mozilla.org/mozilla-central/rev/15077ee67520
https://hg.mozilla.org/mozilla-central/rev/60070da355a6
https://hg.mozilla.org/mozilla-central/rev/900d0863e9a4
Status: NEW → RESOLVED
Closed: 10 years ago
status-firefox42:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla42
You need to log in
before you can comment on or make changes to this bug.
Description
•