Replace native division with integer division

This commit is contained in:
Jason Freeman 2014-09-22 13:50:05 -07:00
parent 2fa24a7e7a
commit fd43211d6a
2 changed files with 5 additions and 1 deletions

View File

@ -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;

View File

@ -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);
}