[WIP] Replace top-level event types with numbers #11894
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a rough proof of concept.
Not sure if it's worth it, but it removes about 0.5K post min+gzip.
The idea is to use number constants since
top*
strings don't have special meanings anyway. I'm using ESM exports because GCC can inline those numbers.A few observations:
on*
as the "base" name and thus ensure it stays interned (and only the rareon*Capture
would be uninterned). Not sure where we compare to it so don't know if it makes a difference.mediaEvents
list inReactDOMFiberComponent
can be an array. There's no need to duplicate raw event names there since they already exist inBrowserEventConstants
.BrowserEventConstants
we could use "Reacty" names fromSimpleEventPlugin
with leadingon
sliced out. Not sure if there's any perf difference in passing an uninterned string toaddEventListener
. There's also a caveat that we don't want to listen to someSimpleEventPlugin
events at top level. But we could still share a list between them if this is beneficial.Still broken: