Closed Bug 1832863 Opened 3 years ago Closed 3 years ago

Consider using methods that don't generate a new URI in the content process

Categories

(Firefox :: Search, task, P1)

task

Tracking

()

RESOLVED FIXED
115 Branch
Tracking Status
firefox115 --- fixed

People

(Reporter: jteow, Assigned: jteow)

References

Details

Attachments

(1 file)

We have a couple places where we call .href or generate a new URI.

This can be costly.

I've saved a SERP on my local machine and triggered categorized 1000 times:

Compare to when I just get the attribute in getAttribute:

The flamegraph shows inspecting the anchor is a pretty costly operation especially due to the generation of a URI anytime we retrieve an href.

Eventually in SearchSERPTelemetry, we'll need to get an absolute URL to match against, but we can look into being more thoughtful on being a bit more efficient. Ideas:

  • Get the href once, and cache that somewhere.
  • Later, if it's relative, manually make it absolute
  • If there is a specific character to convert (i.e. the apostrophe), just using Services.io.newURI to convert everything

If it's too hairy to cache the href, we could just manually construct an absolute href during times when we detect it's a relative URL.

Assignee: nobody → jteow
Status: NEW → ASSIGNED
Pushed by jteow@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/0b628d699ddc Use getAttribute instead of href property - r=scunnane
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 115 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: