Closed Bug 1633770 Opened 5 years ago Closed 5 years ago

Unnecessary loop in ContentSearchUIController._updateDefaultEngineIcon

Categories

(Firefox :: Search, task, P5)

task

Tracking

()

RESOLVED FIXED
Firefox 78
Tracking Status
firefox78 --- fixed

People

(Reporter: standard8, Assigned: gaurijove, Mentored)

Details

(Keywords: good-first-bug, Whiteboard: [lang=js])

Attachments

(1 file)

Currently ContentSearchUIController._updateDefaultEngineIcon is iterating through the engines list to find out the identifier of the default engine:

https://searchfox.org/mozilla-central/rev/158bac3df3a1890da55bdb6ffdaf9a7ffc0bfb0a/browser/base/content/contentSearchUI.js#685-687

      let eng = this._engines.find(
        engine => engine.name === this.defaultEngine.name
      );

      let icon =
        eng && eng.identifier ? this.defaultEngine.icon : DEFAULT_INPUT_ICON;

Rather than iterating through the loop, we should simply store the identifier with alongside the name/icon in set defaultEngine(engine), we can then use that rather directly rather than looping through all the engines.

Priority: -- → P5

Hello, May I submit a patch for this? :)

(In reply to Jayati Shrivastava from comment #1)

Hello, May I submit a patch for this? :)

As this is a good first bug, and you've already done a few, could we leave this for a newer contributor? If you're looking for another bug then bug 1624733 is a bit more advanced, and don't forget about your other current assigned bugs as well.

Assignee: nobody → gaurijove
Status: NEW → ASSIGNED

Sorry Mark. I missed seeing your comment before submitting the patch. Should I abandon it?

Flags: needinfo?(standard8)

No, that's fine, it is done now.

Flags: needinfo?(standard8)
Pushed by mbanner@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/c9d662b12de5 Remove unnecessary loop in ContentSearchUIController._updateDefaultEngineIcon.r=Standard8
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 78
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: