Closed Bug 1104139 Opened 11 years ago Closed 11 years ago

[Contacts] Refactor highlight so we can avoid using regexp

Categories

(Firefox OS Graveyard :: Gaia::Contacts, defect)

x86_64
Linux
defect
Not set
normal

Tracking

(b2g-master fixed)

RESOLVED FIXED
2.2 S4 (23jan)
Tracking Status
b2g-master --- fixed

People

(Reporter: hola, Assigned: hola)

References

Details

Attachments

(1 file)

46 bytes, text/x-github-pull-request
jmcf
: review+
crdlc
: feedback+
Details | Review
To have a more simple code and improve performance we should refactor highlighting in contact search to avoid using regular expressions.
Target Milestone: --- → 2.2 S1 (5dec)
Assignee: nobody → hola
Attached file Pull request
Do you think this is the correct approach? Highlighting tests are already passing. I haven't changed the highlighting tag because it changed styles even using the corresponding class, so maybe we should try to do the change in a future bug. If you are ok with this, I will ask to know where inside shared this function should be. Thanks!
Attachment #8529195 - Flags: feedback?(jmcf)
Depends on: 1088706
Comment on attachment 8529195 [details] [review] Pull request we need more work on this
Attachment #8529195 - Flags: feedback?(jmcf)
Comment on attachment 8529195 [details] [review] Pull request I would like to ask someone from shared if they are ok with using that file for the highlighting function, because the file seems to be unused and deprecated. Apart from that, tests are passing and highlighting works fine for me.
Attachment #8529195 - Flags: review?(jmcf)
(In reply to Adrián de la Rosa from comment #4) > Comment on attachment 8529195 [details] [review] > Pull request > > I would like to ask someone from shared if they are ok with using that file > for the highlighting function, because the file seems to be unused and > deprecated. Apart from that, tests are passing and highlighting works fine > for me. We can ask Julien if the shared/js/utils.js is going to be deprecated or not. Nonetheless I still find it useful to share the highlight function in gaia/shared. thanks
Flags: needinfo?(felash)
Comment on attachment 8529195 [details] [review] Pull request we are on the right track, please address the comments on GH, and then we would need to add to the patch additional unit tests (if needed) and a brand new integration test suite for contacts search. thanks!
Attachment #8529195 - Flags: review?(jmcf)
I'm not a "shared" peer, redirecting the NI to Kevin. Clearly createHighlightHTML is not used anywhere currently. In the file it's said it comes from the SMS app, but the blame shows that this part actually came from the Browser app, and was likely moved to shared afterwards. In the SMS app we currently have a different implementation using Template.
Flags: needinfo?(felash) → needinfo?(kgrandon)
I'm fine using this file. This utility should arguably be its own file, though you don't have to do that in this pull request. I think I prefer the regular expression approach personally. Have we checked if there's a performance difference between using a word list and a regular expression?
Flags: needinfo?(kgrandon)
Comment on attachment 8529195 [details] [review] Pull request Before asking for another review, I would like your opinion about some issues. First, I wasn't able to find where search.js was loaded from contacts so I lazyLoaded a related file here: https://github.com/mozilla-b2g/gaia/pull/26492/files?diff=unified#diff-139a10c960db3187930ef89ff828a686R183 . Jose Manuel noted that it should be lazyloaded with the rest of search dependencies. Second, Jose Manuel left this comment: https://github.com/mozilla-b2g/gaia/pull/26492/files?diff=unified#r21031394 but I'm not sure about what does he means, and he's on pto right now. And last, this suggestion from Kevin that I think you should know how to answer better than me: https://github.com/mozilla-b2g/gaia/pull/26492/files?diff=unified#r21061559 Thanks!
Attachment #8529195 - Flags: feedback?(francisco)
(In reply to Adrián de la Rosa from comment #9) > Comment on attachment 8529195 [details] [review] > Pull request > > Before asking for another review, I would like your opinion about some > issues. First, I wasn't able to find where search.js was loaded from > contacts so I lazyLoaded a related file here: > https://github.com/mozilla-b2g/gaia/pull/26492/files?diff=unified#diff- > 139a10c960db3187930ef89ff828a686R183 . Jose Manuel noted that it should be > lazyloaded with the rest of search dependencies. Right now the search dependency is loaded using the views loading mechanism, take a look to the |loadView| method (and you'll be redirected to |load|) inside |contacts.js| > > Second, Jose Manuel left this comment: > https://github.com/mozilla-b2g/gaia/pull/26492/files?diff=unified#﷒0﷓ but > I'm not sure about what does he means, and he's on pto right now. I guess that Jose is talking to store in two arrays the positions that you have to highlight or keep as they are. > > And last, this suggestion from Kevin that I think you should know how to > answer better than me: > https://github.com/mozilla-b2g/gaia/pull/26492/files?diff=unified#﷒1 I already replied in github. Also I agree with Kevin, I prefer to remove stuff from the |shared/js/utilities.js| seems we are loading a lot of stuff that we won't need. > > Thanks! More extra feedback, remember that search is shared cause it's also used in FTU, which means that we will need to add any extra dependency (if needed) to the importers (in contacts and ftu). As well, don't know if more people is using the old highlight method, in that case will be nice to leave the previous one, as the regexp will be quite faster. I understant that the highlight requirements in contacts are different (for example one string ñ, should highlight if we search by n), so if this highligth method is used in other place, would keep it and add a new one, if not, I'm ok with modifying it.
Attachment #8529195 - Flags: feedback?(francisco)
Comment on attachment 8529195 [details] [review] Pull request The PR has now two commits, one being from bug 1100930. We can mark the other as duplicate of this, or I can rebase into master once the other bug is accepted. I need the function I created for the other bug because I can't use textContent since I need to know where the <strong> tag is, but if I use innerHTML I will get the content encoded.
Attachment #8529195 - Flags: review?(francisco)
Attachment #8529195 - Flags: feedback?(crdlc)
Blocks: 1100871
Comment on attachment 8529195 [details] [review] Pull request Left some comments, good job. Just a suggestion, I think that we should re-implement integration tests already existing properly and add a suite to test this new behavior thought
Attachment #8529195 - Flags: feedback?(crdlc) → feedback+
Comments solved, thanks for your suggestions!
Removed commit from bug 1100930. Marking this bug as depending on 1100930 to make clear there's missing code here. I'll rebase this PR when that one lands.
Depends on: 1100930
Comment on attachment 8529195 [details] [review] Pull request Left a couple of comments in the PR, pretty tiny, could you address them and rebase? And once we have a clean build we can land this. Thanks!
Attachment #8529195 - Flags: review?(francisco)
Comment on attachment 8529195 [details] [review] Pull request Comments addressed!
Attachment #8529195 - Flags: review?(francisco)
Comment on attachment 8529195 [details] [review] Pull request Codewise looking ok, but unit tests and integration tests are failing for contact search: https://treeherder.mozilla.org/ui/#/jobs?repo=gaia-try&revision=9c82d9bc1dab
Attachment #8529195 - Flags: review?(francisco) → review-
Oh, I forgot this patch needs bug 1100930 to land first. I'll ask for review again once that happens.
Comment on attachment 8529195 [details] [review] Pull request Asking for review now that the bug that was blocking this one is merged in master.
Attachment #8529195 - Flags: review- → review?(jmcf)
Comment on attachment 8529195 [details] [review] Pull request please address the latest comments on GH and land once you get a green tree thanks!
Attachment #8529195 - Flags: review?(jmcf) → review+
Every test passed! Asking for check in.
Keywords: checkin-needed
Status: NEW → RESOLVED
Closed: 11 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: 2.2 S1 (5dec) → 2.2 S4 (23jan)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: