Skip to content

Comments

Use faster mechanism for type checks against DOM nodes#403

Merged
schultek merged 2 commits intoschultek:mainfrom
mkustermann:perf-type-checks
Mar 24, 2025
Merged

Use faster mechanism for type checks against DOM nodes#403
schultek merged 2 commits intoschultek:mainfrom
mkustermann:perf-type-checks

Conversation

@mkustermann
Copy link
Contributor

@mkustermann mkustermann commented Mar 19, 2025

The

  • <node>.isA<HTMLInputElement>() and
  • <node>.instanceOfString('HTMLInputElement')

APIs are currently performing poorly, see [0].

Instead we use <node>.instanceof(<constructor>) with a cached value of the looked up constructor.
=> This results in 5-10x faster type checks in dart2wasm.

[0] dart-lang/sdk#60344

The

  * `<node>.isA<HTMLInputElement>()` and
  * `<node>.instanceOfString('HTMLInputElement')`

APIs are currently performing poorly, see [0].

Instead we use `<node>.instanceof(<constructor>)` with a cached value of
the looked up constructor. This results in 5-10x faster type checks in
dart2wasm.

[0] dart-lang/sdk#60344
@mkustermann mkustermann requested a review from schultek as a code owner March 19, 2025 12:27
@docs-page
Copy link

docs-page bot commented Mar 19, 2025

To view this pull requests documentation preview, visit the following URL:

docs.page/schultek/jaspr~403

Documentation is deployed and generated using docs.page.

@github-actions
Copy link

Package Version Report

The following packages have been updated:
jaspr : 0.18.0 -> 0.18.1
jaspr_builder : 0.18.0 -> 0.18.1
jaspr_cli : 0.18.0 -> 0.18.1
jaspr_test : 0.18.0 -> 0.18.1

Copy link
Owner

@schultek schultek left a comment

Choose a reason for hiding this comment

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

Great stuff, thanks!

@schultek schultek merged commit d25dd70 into schultek:main Mar 24, 2025
3 checks passed
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.

2 participants