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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/utility.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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.


export function read(filename) {
const absolute = find(filename);
return fs.readFileSync(absolute).toString();
return fs.readFileSync(absolute, 'utf8');
}

export function find(filename) {
Expand Down
Loading