From fd43211d6ac3d4330cf8e778a16d2014ec703d5d Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Mon, 22 Sep 2014 13:50:05 -0700 Subject: [PATCH] Replace native division with integer division --- src/compiler/core.ts | 4 ++++ src/services/signatureHelp.ts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index fb2bde52453..90316f46ad7 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -121,6 +121,10 @@ module ts { } return ~low; + } + + export function integerDivide(numerator: number, denominator: number): number { + return (numerator / denominator) >> 0; } var hasOwnProperty = Object.prototype.hasOwnProperty; diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index 8986664eeb0..b7355ae7ad1 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -487,7 +487,7 @@ module ts.SignatureHelp { // the applicable span and that we are typing the last argument // Alternatively, we could be in range of one of the arguments, in which case we need to divide // by 2 to exclude commas - var argumentIndex = indexOfNodeContainingPosition < 0 ? argumentCount - 1 : indexOfNodeContainingPosition / 2; + var argumentIndex = indexOfNodeContainingPosition < 0 ? argumentCount - 1 : integerDivide(indexOfNodeContainingPosition, 2); return new SignatureHelpState(argumentIndex, argumentCount); }