Skip to content

Class emit: cached repeat prototype sets in a variable #33363

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

Closed

Conversation

JoshuaKGoldberg
Copy link
Contributor

@JoshuaKGoldberg JoshuaKGoldberg commented Sep 11, 2019

If two or more class members would assign to the class .prototype, that'll be stored in a temporary variable named like proto per @kitsonk's suggestion. This approach is similar to #16469 but with the the original behavior preserved for classes with only one prototype member.

Does not return the class prototype from __extends for further terseness; I'd be interested in taking that on next.

Fixes #9638.

This PR contains <100 lines of real code change and >350 files of test changes. Fun!

Waiting to update the last few baselines on #33364. They seem to be generally acceptable? I'll just fix them manually.

If two or more class members would assign to the class `.prototype`, that'll be stored in a temporary variable named like `proto`.
@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review September 11, 2019 00:49
@JoshuaKGoldberg JoshuaKGoldberg changed the title Class emit: cached repeat prototype repetitions in a variable Class emit: cached repeat prototype sets in a variable Sep 11, 2019
@JoshuaKGoldberg
Copy link
Contributor Author

Ping @DanielRosenwasser - this, #33337, and #29374 have been sitting for a little while. Do you think someone would be able to take a look at them soon? Thanks!

@sandersn sandersn added the For Backlog Bug PRs that fix a backlog bug label Feb 1, 2020
@rbuckton
Copy link
Member

rbuckton commented Jan 8, 2021

@JoshuaKGoldberg we discussed this in the design meeting today. As you mention above, a previous attempt (#16469) to address this was made before. At the time it was determined that zlib compression can already handle repeated ClassName.prototype sections efficiently and there was not much to gain by this. This was reiterated again in todays design meeting with the added caveat is that this new output actually makes it harder for TypeScript to analyze the resulting JS code (say, if someone were to ship compiled TypeScript without declaration files). While I appreciate the effort that went into this PR, we've decided we are unlikely to take this change due to these factors.

@JoshuaKGoldberg
Copy link
Contributor Author

Ok, thanks for letting me know and discussing! It was a fun learning experience regardless. 😄

@JoshuaKGoldberg JoshuaKGoldberg deleted the class-proto-caches branch January 8, 2021 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Suggestion: put prototype in var for better minification
3 participants