Closed Bug 1406488 Opened 7 years ago Closed 7 years ago

Use a set to store current visits in `_recordToPlaceInfo`

Categories

(Firefox :: Sync, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
Firefox 58
Tracking Status
firefox58 --- fixed

People

(Reporter: lina, Assigned: ilphrin, Mentored)

Details

(Keywords: good-first-bug)

Attachments

(1 file, 2 obsolete files)

We currently use an array to store `curVisits`: https://searchfox.org/mozilla-central/rev/8efd128b48cdae3a6c6862795ce618aa1ca1c0b4/services/sync/modules/engines/history.js#248,255-258,285,293 Using a set here would be more efficient, as we'd avoid a linear search to look up every visit key.
Hi! Can I take this bug? It is my very first bug. I have built Firefox and am testing some code modifications
(In reply to Kevin Pellet (Ilphrin) from comment #1)
> Hi! Can I take this bug? It is my very first bug. I have built Firefox and
> am testing some code modifications

Yes, that would be great, and thanks for wanting to get involved! Please upload a first version of a patch, and we'll then both assign the bug to you and let you know what changes, if any, need to be made.
Attached patch bug1406488.patch (obsolete) — Splinter Review
So here is my first proposal for fixing this bug!
Attachment #8917049 - Flags: review?(kit)
Comment on attachment 8917049 [details] [diff] [review]
bug1406488.patch

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

Thanks very much for your first patch, Kevin! Please fix up the `fetchVisitsForURL` issue, and run `./mach xpcshell-test services/sync/tests/unit/test_history_store.js` to make sure the tests still pass. Once that's fixed, I'll r+ and we can land. \o/

::: services/sync/modules/engines/history.js
@@ +251,1 @@
>      } catch (e) {

This won't work as written, unfortunately. `fetchVisitsForURL` returns an array of `{ date, type }` tuples, but `curVisits` needs to be a set of string keys. You'll want to iterate over the visits, change them to `visit.date + "," + visit.type`, and add those to the set instead, like the old loop did.
Attachment #8917049 - Flags: review?(kit)
Assignee: nobody → ilphrin
Status: NEW → ASSIGNED
Attached patch bug1406488.patch (obsolete) — Splinter Review
Oh! I thought the point was to remove this loop when replacing by a Set, but after testing with jsFiddle I understood that using objects for a Set is... meh. I understand more now. I've uploaded another patch which iterates over the array to generate the Set.

All the tests are successful.
Attachment #8917229 - Flags: review?(kit)
Comment on attachment 8917229 [details] [diff] [review]
bug1406488.patch

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

Looks good! Please squash the two commits into a single patch, add "r=kitcambridge" to the commit message, and then we can get this checked in.
Attachment #8917229 - Flags: review?(kit)
Cool =D I had some difficulties handling hg commands, but here is the final patch with the two commits merged.
Ah, bad file name, the file should be named bug1406488_publish.patch, sorry
Comment on attachment 8917605 [details] [diff] [review]
bug1406588_publish.patch

Awesome, thanks!
Attachment #8917605 - Flags: review+
Attachment #8917229 - Attachment is obsolete: true
Attachment #8917049 - Attachment is obsolete: true
Pushed by kcambridge@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/f160ec9ff8bd
Use a set instead of array to store current visits in `_recordToPlaceInfo` r=kitcambridge
https://hg.mozilla.org/mozilla-central/rev/f160ec9ff8bd
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 58
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: