Skip to content
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

Remove unused isPowerOfTwo function from JS compiler. NFC #23353

Merged
merged 1 commit into from
Jan 9, 2025

Conversation

sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Jan 9, 2025

Also, add utf8 to read function to avoid the extra toString() call (which itself defaults to utf8).

@sbc100 sbc100 requested a review from kripken January 9, 2025 17:05
Also, add `utf8` to read function to avoid the extra `toString()` call
(which itself defaults to `utf8`).
@@ -231,13 +231,9 @@ export function isDecorator(ident) {
return suffixes.some((suffix) => ident.endsWith(suffix));
}

export function isPowerOfTwo(x) {
return x > 0 && (x & (x - 1)) == 0;
}
Copy link
Member

Choose a reason for hiding this comment

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

This may be used by user JS libraries - is it worth removing? If so, let's at least mention in the changelog?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, the way these "exports" work is only to other ES6 modules that make up the compiler.

The JS libraries don't have visibility of these symbols, by design. JS libraries can only see symbols that are explictly added using addToCompileTimeContext. This function (isPowerOfTwo) is not one of those.

Copy link
Member

@kripken kripken Jan 9, 2025

Choose a reason for hiding this comment

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

Oh, nice, I wasn't aware that ES6 modules limited things that way.

@sbc100 sbc100 merged commit 0585506 into emscripten-core:main Jan 9, 2025
29 checks passed
@sbc100 sbc100 deleted the remove_unused branch January 9, 2025 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants