Skip to content

script: Do not unnecessary clone CSP list in Document::get_csp_list#42716

Merged
TimvdLippe merged 2 commits intoservo:mainfrom
Narfinger:csp-ref
Feb 23, 2026
Merged

script: Do not unnecessary clone CSP list in Document::get_csp_list#42716
TimvdLippe merged 2 commits intoservo:mainfrom
Narfinger:csp-ref

Conversation

@Narfinger
Copy link
Copy Markdown
Contributor

We previously clonsed the CSP list unnecessarily which consisted of roughly 2.7%. 1.2% spend in Document::get_csp_list.
We can easily avoid it with Ref and cloning it deliberately when needed.

Testing: This is functionally identical to the previous code as it is a change from clone to a Ref<>.

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
@Narfinger Narfinger requested a review from gterzian as a code owner February 19, 2026 16:26
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Feb 19, 2026
@mrobinson mrobinson changed the title script: Do not unnecessary clone CSP List script: Do not unnecessary clone CSP list in Document::get_csp_list Feb 19, 2026
Copy link
Copy Markdown
Member

@mrobinson mrobinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Feb 19, 2026
Copy link
Copy Markdown
Contributor

@TimvdLippe TimvdLippe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that document.get_csp_list is similar to globalscope.get_csp_list. Is the same optimization applicable there?

Comment thread components/script/dom/document.rs Outdated
@Narfinger
Copy link
Copy Markdown
Contributor Author

I am not sure to be honest. I will look at it tomorrow but I didn't want to figure out where the process/threads bounds in it where.

@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Feb 23, 2026
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
@Narfinger
Copy link
Copy Markdown
Contributor Author

So update on globalscope.get_csp_list. Most of them are copied into structures so it doesn't make much sense to change this.

Copy link
Copy Markdown
Contributor

@TimvdLippe TimvdLippe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for checking!

@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Feb 23, 2026
@TimvdLippe TimvdLippe added this pull request to the merge queue Feb 23, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Feb 23, 2026
Merged via the queue into servo:main with commit c6a5eb5 Feb 23, 2026
33 checks passed
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Feb 23, 2026
@Narfinger Narfinger deleted the csp-ref branch February 23, 2026 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants