From 470e1057613f5e48aa4508d8285075db38c4180b Mon Sep 17 00:00:00 2001 From: HerrintonDarkholme <2883231+HerringtonDarkholme@users.noreply.github.com> Date: Sun, 23 Oct 2022 14:16:12 -0400 Subject: [PATCH] chore: use shift operator instead of Math.pow --- plugins/typescript/src/services/semanticTokens.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/typescript/src/services/semanticTokens.ts b/plugins/typescript/src/services/semanticTokens.ts index 03701c1c4..b8e0e2d3d 100644 --- a/plugins/typescript/src/services/semanticTokens.ts +++ b/plugins/typescript/src/services/semanticTokens.ts @@ -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); @@ -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; } } }