Skip to content

Conversation

@liuxingbaoyu
Copy link
Member

Q                       A
Fixed Issues? Fixes #1, Fixes #2
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

This PR itself is not an improvement, but it opens up the possibility for future output size improvements.
I also migrated the helpers to ts so that we can use vscode's reference analysis.

Comment on lines +7 to +8
setter: Function,
receiver: any,
Copy link
Member

Choose a reason for hiding this comment

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

If we swap these two parameters it will probably gzip slightly better, because privateMap, receiver will be next to each other both times.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, just because setter may be bind. :)

@nicolo-ribaudo
Copy link
Member

but it opens up the possibility for future output size improvements.

Do you have any example?

Comment on lines 26 to 34
[_init_a, _get_a, _set_a, _init_b, _get_b, _set_b, _initProto] = babelHelpers.applyDecs(_Foo, [[dec, 1, "a", function () {
return babelHelpers.classPrivateFieldGet2(this, _A);
return babelHelpers.classPrivateFieldGet2(_A, this);
}, function (value) {
babelHelpers.classPrivateFieldSet2(this, _A, value);
babelHelpers.classPrivateFieldSet2(_A, this, value);
}], [dec, 1, "b", function () {
return babelHelpers.classPrivateFieldGet2(this, _B);
return babelHelpers.classPrivateFieldGet2(_B, this);
}, function (value) {
babelHelpers.classPrivateFieldSet2(this, _B, value);
babelHelpers.classPrivateFieldSet2(_B, this, value);
}]], []);
Copy link
Member Author

@liuxingbaoyu liuxingbaoyu Feb 24, 2024

Choose a reason for hiding this comment

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

I want to try to optimize them to avoid an extra function.
It's a little difficult to be honest, but worth trying. :)

[_init_a, _get_a, _set_a, _init_b, _get_b, _set_b, _initProto] = babelHelpers.applyDecs(_Foo, [[dec, 1, "a", 
bind(babelHelpers.classPrivateFieldGet2, _A), 
bind(babelHelpers.classPrivateFieldSet2, _A)], [dec, 1, "b", 
bind(babelHelpers.classPrivateFieldGet2, _B), 
bind(babelHelpers.classPrivateFieldSet2, _B)]], []);

Comment on lines +16 to 21
function _get_privateFieldValue(_this) {
return babelHelpers.classPrivateFieldGet2(_privateField, _this);
}
function _set_privateFieldValue(newValue) {
babelHelpers.classPrivateFieldSet2(this, _privateField, newValue);
function _set_privateFieldValue(_this2, newValue) {
babelHelpers.classPrivateFieldSet2(_privateField, _this2, newValue);
}
Copy link
Member Author

@liuxingbaoyu liuxingbaoyu Feb 25, 2024

Choose a reason for hiding this comment

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

I pushed another commit and now they can bind _privateField to save some size.

If you want to keep this PR easy to review I can revert it and open a new PR. )

I also need to handle arguments. :)

Copy link
Member

Choose a reason for hiding this comment

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

I like this change -- passing this as a parameter also makes minification better because it can be renamed.

Copy link
Member Author

Choose a reason for hiding this comment

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

I am doing a special case for arguments. :)

@nicolo-ribaudo nicolo-ribaudo added this to the v7.24.0 milestone Feb 27, 2024
@babel-bot
Copy link
Collaborator

babel-bot commented Feb 27, 2024

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/56348

Comment on lines 19 to 21
var _set_privateFieldValue = babelHelpers.curryThis(function _set_privateFieldValue(newValue) {
babelHelpers.classPrivateFieldSet2(_privateField, this, arguments[0]);
});
Copy link
Member Author

Choose a reason for hiding this comment

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

In this case, the output becomes worse, but I think this is an extreme situation.

@nicolo-ribaudo
Copy link
Member

@liuxingbaoyu I was going to merge this PR because I have another PR to open on top of it -- could you remove the last commit and push it in a new PR to give time to review it? 🙏

@nicolo-ribaudo nicolo-ribaudo changed the title Move helper parameters Move new private elements helper parameters Feb 27, 2024
@nicolo-ribaudo nicolo-ribaudo merged commit ccf1a67 into babel:feat-7.24.0/decorators Feb 27, 2024
@liuxingbaoyu
Copy link
Member Author

liuxingbaoyu commented Feb 27, 2024

@nicolo-ribaudo Sorry, I seem to have done something wrong. There is still the second Commit in this PR, I don't understand why. 😞

image
My VS Code does not show the second Commit, which is strange.

Oh, what you mean is that there is only the last commit, so this may not matter. : :)

@nicolo-ribaudo
Copy link
Member

nicolo-ribaudo commented Feb 27, 2024

Yes sorry, I re-pushed it when merging 😅 But today and yesterday GitHub has been having problems with showing pushes in PRs.

liuxingbaoyu added a commit to liuxingbaoyu/babel that referenced this pull request Mar 5, 2024
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label May 29, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants