Closed Bug 997777 Opened 10 years ago Closed 10 years ago

Optimize moveToPosition() performance in TopSitesCursorWrapper

Categories

(Firefox for Android Graveyard :: Awesomescreen, defect)

All
Android
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Firefox 32

People

(Reporter: lucasr, Assigned: lucasr)

References

Details

Attachments

(2 files)

Right now, it moves the position of all wrapper cursors, even when some of them will not be used for the new position anyway.
Comment on attachment 8408360 [details] [diff] [review]
Throw exception if pinned site is not within min size (r=wesj)

The following optimization assumes pinned sites are never beyond minSize. So, let's make sure this is the case first (and catch any existing bugs related to this).
Attachment #8408360 - Flags: review?(wjohnston)
Comment on attachment 8408361 [details] [diff] [review]
Optimize moveToPosition() in TopSitesCursorWrapper (r=wesj)

Avoid moving the position of all wrapped cursors if possible.
Attachment #8408361 - Flags: review?(wjohnston)
Comment on attachment 8408360 [details] [diff] [review]
Throw exception if pinned site is not within min size (r=wesj)

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

This goes directly against my plans to make this multi-cursor-wrapper less aware of the cursors in it. It means the pinned sites cursor will have to be aware of how its being shown.
Attachment #8408360 - Flags: review?(wjohnston) → review-
Comment on attachment 8408361 [details] [diff] [review]
Optimize moveToPosition() in TopSitesCursorWrapper (r=wesj)

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

I really don't mind the min checks here. Its easy to not take them when we do something more generic. I think the throw in the previous patch makes it feel like we are setting an invariant about the pinned sites cursor that I think I don't really love... i.e. pinnedSites shouldn't care where they are, but these wrappers can enforce that we don't show them outside the list.

I do think you should consolidate the logic a bit though into some shared methods (that hopefully will eventually be the only methods when we're done).

::: mobile/android/base/db/TopSitesCursorWrapper.java
@@ +203,3 @@
>          }
>  
> +        if (position >= minSize) {

Removing this bit gets trickier, since we might have 100 (or 9) suggested sites in the cursor but you only want ones that would appear as thumbnails (the 6 on phones) (i.e. this is the place where the cursor needs to know about how its displayed maybe? Or maybe if we really believe in our suggestions, they should show below the top sites grid if we've got them...).

I think we'll need a custom CursorWrapper around the pinned and suggested sites eventually...

@@ +206,5 @@
> +            return false;
> +        }
> +
> +        final int index = position - pinnedBefore - topCursor.getCount();
> +        if (index >= 0 && index < suggestedCursor.getCount()) {

From here on out, this and the topSites cursor are essentially identical. We should just have a single method that takes a cursor, position, and RowType.
Attachment #8408361 - Flags: review?(wjohnston) → review+
(In reply to Wesley Johnston (:wesj) from comment #6)
> Comment on attachment 8408361 [details] [diff] [review]
> Optimize moveToPosition() in TopSitesCursorWrapper (r=wesj)
> 
> Review of attachment 8408361 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> I really don't mind the min checks here. Its easy to not take them when we
> do something more generic. I think the throw in the previous patch makes it
> feel like we are setting an invariant about the pinned sites cursor that I
> think I don't really love... i.e. pinnedSites shouldn't care where they are,
> but these wrappers can enforce that we don't show them outside the list.

Ok, I'll drop the patch that enforces pinned site positions to be without min size for now.

> ::: mobile/android/base/db/TopSitesCursorWrapper.java
> @@ +203,3 @@
> >          }
> >  
> > +        if (position >= minSize) {
> 
> Removing this bit gets trickier, since we might have 100 (or 9) suggested
> sites in the cursor but you only want ones that would appear as thumbnails
> (the 6 on phones) (i.e. this is the place where the cursor needs to know
> about how its displayed maybe? Or maybe if we really believe in our
> suggestions, they should show below the top sites grid if we've got them...).
> 
> I think we'll need a custom CursorWrapper around the pinned and suggested
> sites eventually...

Yeah, I expect we'll need some sort of inner wrapper for bug 1001397. 

> @@ +206,5 @@
> > +            return false;
> > +        }
> > +
> > +        final int index = position - pinnedBefore - topCursor.getCount();
> > +        if (index >= 0 && index < suggestedCursor.getCount()) {
> 
> From here on out, this and the topSites cursor are essentially identical. We
> should just have a single method that takes a cursor, position, and RowType.

Good point, done.
https://hg.mozilla.org/mozilla-central/rev/fa62732307ee
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 32
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: