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

chore: use shift operator instead of Math.pow #2053

Merged
merged 1 commit into from Oct 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions plugins/typescript/src/services/semanticTokens.ts
Expand Up @@ -50,11 +50,11 @@ export function register(
}

const serverToken = tsTokenTypeToServerTokenType(tokenType);
const serverTokenModifiers = tsTokenModifierToServerTokenModifier(tokenModifiers);
if (serverToken === undefined) {
continue;
}

const serverTokenModifiers = tsTokenModifierToServerTokenModifier(tokenModifiers);
// we can use the document's range conversion methods because the result is at the same version as the document
const startPos = document.positionAt(offset);
const endPos = document.positionAt(offset + length);
Expand All @@ -74,10 +74,10 @@ export function register(
function tsTokenModifierToServerTokenModifier(input: number) {
let m = 0;
for (let i = 0; i < tokenModifiers.length; i++) {
if (input & Math.pow(2, i)) {
if (input & (1 << i)) {
const match = legend.tokenModifiers.indexOf(tokenModifiers[i]);
if (match >= 0) {
m |= Math.pow(2, match);
m |= 1 << match;
}
}
}
Expand Down