-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reverse Enum Member Initialization Order for Constants #12693
Comments
this assumes a side-effect free initialization expressions. consider: enum A {
Name = increment(),
LongName = increment(),
ReallyLongName = increment()
} with getters being part of the language, any property access can not guaranteed to be side-effect free, so we would have different emit for enums with auto-initialized members or const-expression-initialized, vs. ones with non-const-expression-initialized enums. why not use |
Precisely - the suggestion here is for enums which are known to be const-initialized and side-effect free, something we already have means of tracking. |
It'd be a runtime breaking change to do this because enums with duplicate values would reverse map to a different name in this emit. |
Consider the following enum.
It's javascript output is
but would be much more succinct if it were output as
The only benefit to this change would be minification of the output javascript. Running the two versions in a minifier I'm getting the current output minified at 116 bytes and the proposed way at 96 bytes for a difference of about 17%. Obviously, this difference would be influenced by the number of enum members and the length of the enum members' names.
This change would only be applicable to enum members with a constant value.
The text was updated successfully, but these errors were encountered: