Skip to content

Commit fd43211

Browse files
committed
Replace native division with integer division
1 parent 2fa24a7 commit fd43211

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/compiler/core.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ module ts {
121121
}
122122

123123
return ~low;
124+
}
125+
126+
export function integerDivide(numerator: number, denominator: number): number {
127+
return (numerator / denominator) >> 0;
124128
}
125129

126130
var hasOwnProperty = Object.prototype.hasOwnProperty;

src/services/signatureHelp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ module ts.SignatureHelp {
487487
// the applicable span and that we are typing the last argument
488488
// Alternatively, we could be in range of one of the arguments, in which case we need to divide
489489
// by 2 to exclude commas
490-
var argumentIndex = indexOfNodeContainingPosition < 0 ? argumentCount - 1 : indexOfNodeContainingPosition / 2;
490+
var argumentIndex = indexOfNodeContainingPosition < 0 ? argumentCount - 1 : integerDivide(indexOfNodeContainingPosition, 2);
491491
return new SignatureHelpState(argumentIndex, argumentCount);
492492
}
493493

0 commit comments

Comments
 (0)