Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

visitorKeys is needed for prettier #1467

Merged
merged 12 commits into from
Oct 27, 2023
Merged

visitorKeys is needed for prettier #1467

merged 12 commits into from
Oct 27, 2023

Conversation

NullVoxPopuli
Copy link
Contributor

@NullVoxPopuli NullVoxPopuli commented Oct 27, 2023

Resolves: #1465 and #1436


QUnit.module('[glimmer-syntax] Public API is unchanged');

QUnit.test('exports are not accidentally removed', function(assert) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

if there is a better way to do this, I'd be all ears. I think it'd be great to have some sort of snapshot tool to at least automatically manage Object.keys(syntax)

@@ -32,6 +32,8 @@ export type { NodeVisitor } from './lib/traversal/visitor';
export { default as Walker } from './lib/traversal/walker';
export * as ASTv1 from './lib/v1/api';
export { default as builders } from './lib/v1/public-builders';
export { default as visitorKeys } from './lib/v1/visitor-keys';
export { voidMap } from './lib/generation/printer';
Copy link
Contributor

@fisker fisker Oct 27, 2023

Choose a reason for hiding this comment

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

Since voidMap is generated from array, can we export the array instead?

voidTagNames.split(' ').forEach((tagName) => {

Copy link
Contributor

Choose a reason for hiding this comment

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

I also suggest switch to use Set internally.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, I'm a fan of this -- one less module-load-time thing to do. Gonna type out this array, and not have this runtime code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also suggest switch to use Set internally.

good thinkin -- we're still cleaning up from back when Set wasn't available everywhere

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tho, according to: https://perf.link/#eyJpZCI6InJ4YmdkMGthcWtmIiwidGl0bGUiOiJGaW5kaW5nI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sOTAxODAwMCw0Mjc1MDAwLDI4ODcwMDAsNjAyNTAwMCwxMTEwOTAwMCw4NTkwMDAsMzc5MTAwMCwxNzk3MDAwLDMxNzgwMDAsMTE5NTMwMDAsMTUwNzEwMDAsMTMxNTMwMDAsMTE4ODMwMDAsMTI5NjAwMDAsMzcwMDAsMTEzNjgwMDAsODE5MzAwMCw3MzAxMDAwLDkxNTcwMDAsMTAzOTMwMDAsMTQxMjYwMDAsMTIyOTEwMDAsODQ5NTAwMCwzNDQ3MDAwLDQ3NTUwMDAsMzEyMzAwMCwxMzQwNjAwMCwxMjMxMzAwMCw3MDgzMDAwLDEyNzEwMDAwLDEwODMzMDAwLDgyMTYwMDAsMTcxODcwMDAsNTg1MTAwMCw3NTY0MDAwLDQ4NzYwMDAsMTk0ODAwMCw2NjQzMDAwLDkyNDAwMDAsMjE4MjAwMCwxNDE0MDAwLDE4OTM5MDAwLDgxNjUwMDAsMTE2MzAwMDAsNjAzMTAwMCwyOTEyMDAwLDQ5ODAwMDAsMTEyMjYwMDAsOTkxNzAwMCwxMDY1MzAwMCwxMDk3MTAwMCw5MzUyMDAwLDExODg2MDAwLDE1OTgwMDAsNjYwNDAwMCwxMTM5OTAwMCwxNTgzMTAwMCwxMzg0NzAwMCwxNTQ0MjAwMCwxNDQxODAwMCwxMjUzNzAwMCwxNDAwNzAwMCwxMjIxMzAwMCwxMTIyMTAwMCwxMTMzNDAwMCw5MTIxMDAwLDQ0NDQwMDAsMTI1MjAwMCw2NDUwMDAwLDkwNjMwMDAsMTI1NTIwMDAsMTE5MDAwMDAsODY3MDAwMCw2MTk3MDAwLDEzMzg1MDAwLDgyMTcwMDAsMTQxNDAwMCw3MDkyMDAwLDg5MDAwMDBdLCJvcHMiOjg3NDI0ODB9XSwidXBkYXRlZCI6IjIwMjMtMTAtMjdUMTY6MjY6MTMuOTIyWiJ9

the object access is way faster

Copy link
Contributor

Choose a reason for hiding this comment

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

You made a mistake

- const voidTagSet = new Set(...voidTagArray);
+ const voidTagSet = new Set(voidTagArray);

yes the object access is very fast, but not much differences.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tyty, all this is generally hotpath code, so every little bit counts!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ooo but map is significantly faster.
https://perf.link/#eyJpZCI6InJ4YmdkMGthcWtmIiwidGl0bGUiOiJGaW5kaW5nIG51bWJlcnMgaW4gYW4gYXJyYXkgb2YgMTAwMCIsImJlZm9yZSI6ImNvbnN0IHZvaWRNYXAgPSBPYmplY3QuY3JlYXRlKG51bGwpO1xuXG5jb25zdCB2b2lkVGFnTmFtZXMgPSBbJ2FyZWEnLCAnYmFzZScsICdicicsICdjb2wnLCAnY29tbWFuZCcsICdlbWJlZCcsICdocicsICdpbWcnLCAnaW5wdXQnLCAna2V5Z2VuJywgJ2xpbmsnLCAnbWV0YScsICdwYXJhbScsICdzb3VyY2UnLCAndHJhY2snLCAnd2JyJ107XG5cbnZvaWRUYWdOYW1lcy5mb3JFYWNoKCh0YWdOYW1lKSA9PiB7XG4gIHZvaWRNYXBbdGFnTmFtZV0gPSB0cnVlO1xufSk7XG5cbmNvbnN0IHZvaWRUYWdBcnJheSA9IE9iamVjdC5rZXlzKHZvaWRNYXApO1xuY29uc3Qgdm9pZFRhZ1NldCA9IG5ldyBTZXQodm9pZFRhZ0FycmF5KTtcbmNvbnN0IHZvaWRUYWdNYXAgPSBuZXcgTWFwKE9iamVjdC5lbnRyaWVzKHZvaWRNYXApKTsiLCJ0ZXN0cyI6W3sibmFtZSI6Ik1hcCBhY2Nlc3MiLCJjb2RlIjoiaWYgKHZvaWRUYWdNYXAuZ2V0KCdsaW5rJykpIHtcblxufSIsInJ1bnMiOls0NzYzMDAwLDY0ODgwMDAsMjQ4MTUwMDAsNDY3NjAwMCwxMTU4MDAwLDEzMjcwMDAsMzY1MzAwMCwzNzgwMDAwLDIzODEwMDAs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TAwMCw4NTEwMDAsMTEwNTAwMCwxODIwMDAsMTA0ODAwMCw5NTIwMDAsMTMxNjAwMCwxODU4MjAwMCwxMzgyMDAwLDgwMDAwLDEzNTgzMDAwLDIzMDAwMDAsMTQ2MDYwMDAsMTMwODIwMDAsNDU3MTAwMCwxMDYwMzAwMCwxOTU1ODAwMCw1MDQ3MDAwLDEzNjA2MDAwLDYwMTUwMDAsNTA0ODAwMCwyMDYzMDAwMCwxOTY3MzAwMCw5MDM3MDAwLDIwNzgzMDAwLDEzNjE0MDAwLDY1MzMwMDAsNjE3MDAwLDE2NDYwMDAsMTM4MjAwMCwxMzgyMDAwLDEyMDQwMDAsOTM2NzAwMF0sIm9wcyI6Nzg1MzQyMH1dLCJ1cGRhdGVkIjoiMjAyMy0xMC0yN1QxNzowNzoxNC43NTRaIn0%3D

@patricklx
Copy link
Contributor

Will this also fix #1436 ?

@NullVoxPopuli
Copy link
Contributor Author

yes!

…t vs Map's perf differences are not important enough right now (since this is build-time code), and maintainability takes precedence in this case
Use a Set for checking if an element is a void element, which is faster than object access
voidTagNames.split(' ').forEach((tagName) => {
voidMap[tagName] = true;
});
export const voidMap = new Set([

This comment was marked as outdated.

Co-authored-by: fisker Cheung <lionkay@gmail.com>
@NullVoxPopuli NullVoxPopuli merged commit cbcc813 into master Oct 27, 2023
5 checks passed
@NullVoxPopuli NullVoxPopuli deleted the export-visitorKeys branch October 27, 2023 20:11
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose voidMap and visitorKeys
3 participants