Skip to content

script: Remove useless upcast::<Element> calls#43824

Merged
yezhizhen merged 1 commit into
servo:mainfrom
webbeef:no-useless-upcast
Apr 1, 2026
Merged

script: Remove useless upcast::<Element> calls#43824
yezhizhen merged 1 commit into
servo:mainfrom
webbeef:no-useless-upcast

Conversation

@webbeef

@webbeef webbeef commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

upcast::() is costly in general, but in some cases we can avoid that call and use a direct field access instead.

Testing: no test change expected.

Signed-off-by: webbeef <me@webbeef.org>
@webbeef webbeef requested a review from gterzian as a code owner April 1, 2026 06:16
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Apr 1, 2026
Comment on lines 1418 to +1419
fn as_element(&self) -> &Element {
self.upcast::<Element>()
&self.element

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I love this change in particular :)

@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Apr 1, 2026
@yezhizhen yezhizhen changed the title script: remove useless upcast::<Element> calls script: Remove useless upcast::<Element> calls Apr 1, 2026
@yezhizhen yezhizhen added this pull request to the merge queue Apr 1, 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 Apr 1, 2026
@xiaochengh

Copy link
Copy Markdown
Contributor

Trying to get more context here. upcast is just a wrapper of mem::transmute, which I assume shouldn't be costly?

@yezhizhen

Copy link
Copy Markdown
Member

Trying to get more context here. upcast is just a wrapper of mem::transmute, which I assume shouldn't be costly?

Probably a typo. I think @webbeef mean "not costly" based on context?

Merged via the queue into servo:main with commit 2518f97 Apr 1, 2026
34 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 Apr 1, 2026
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