mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-12-12 11:36:43 -06:00
inline length
This commit is contained in:
parent
27ed5b8504
commit
2a941a7222
@ -5019,8 +5019,7 @@ namespace ts {
|
||||
// If this is a JSDoc construct signature, then skip the first parameter in the
|
||||
// parameter list. The first parameter represents the return type of the construct
|
||||
// signature.
|
||||
const n = declaration.parameters.length;
|
||||
for (let i = isJSConstructSignature ? 1 : 0; i < n; i++) {
|
||||
for (let i = isJSConstructSignature ? 1 : 0; i < declaration.parameters.length; i++) {
|
||||
const param = declaration.parameters[i];
|
||||
|
||||
let paramSymbol = param.symbol;
|
||||
@ -5119,8 +5118,7 @@ namespace ts {
|
||||
function getSignaturesOfSymbol(symbol: Symbol): Signature[] {
|
||||
if (!symbol) return emptyArray;
|
||||
const result: Signature[] = [];
|
||||
const len = symbol.declarations.length;
|
||||
for (let i = 0; i < len; i++) {
|
||||
for (let i = 0; i < symbol.declarations.length; i++) {
|
||||
const node = symbol.declarations[i];
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.FunctionType:
|
||||
@ -7913,8 +7911,7 @@ namespace ts {
|
||||
return Ternary.False;
|
||||
}
|
||||
let result = Ternary.True;
|
||||
const len = sourceSignatures.length;
|
||||
for (let i = 0; i < len; i++) {
|
||||
for (let i = 0; i < sourceSignatures.length; i++) {
|
||||
const related = compareSignaturesIdentical(sourceSignatures[i], targetSignatures[i], /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, isRelatedTo);
|
||||
if (!related) {
|
||||
return Ternary.False;
|
||||
@ -18047,8 +18044,7 @@ namespace ts {
|
||||
/** Check each type parameter and check that type parameters have no duplicate type parameter declarations */
|
||||
function checkTypeParameters(typeParameterDeclarations: TypeParameterDeclaration[]) {
|
||||
if (typeParameterDeclarations) {
|
||||
const n = typeParameterDeclarations.length;
|
||||
for (let i = 0; i < n; i++) {
|
||||
for (let i = 0; i < typeParameterDeclarations.length; i++) {
|
||||
const node = typeParameterDeclarations[i];
|
||||
checkTypeParameter(node);
|
||||
|
||||
@ -18328,8 +18324,7 @@ namespace ts {
|
||||
// TypeScript 1.0 spec (April 2014):
|
||||
// When a generic interface has multiple declarations, all declarations must have identical type parameter
|
||||
// lists, i.e. identical type parameter names with identical constraints in identical order.
|
||||
const len = list1.length;
|
||||
for (let i = 0; i < len; i++) {
|
||||
for (let i = 0; i < list1.length; i++) {
|
||||
const tp1 = list1[i];
|
||||
const tp2 = list2[i];
|
||||
if (tp1.name.text !== tp2.name.text) {
|
||||
|
||||
@ -119,8 +119,7 @@ namespace ts {
|
||||
*/
|
||||
export function forEach<T, U>(array: T[] | undefined, callback: (element: T, index: number) => U | undefined): U | undefined {
|
||||
if (array) {
|
||||
const len = array.length;
|
||||
for (let i = 0; i < len; i++) {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
const result = callback(array[i], i);
|
||||
if (result) {
|
||||
return result;
|
||||
@ -144,8 +143,7 @@ namespace ts {
|
||||
*/
|
||||
export function every<T>(array: T[], callback: (element: T, index: number) => boolean): boolean {
|
||||
if (array) {
|
||||
const len = array.length;
|
||||
for (let i = 0; i < len; i++) {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
if (!callback(array[i], i)) {
|
||||
return false;
|
||||
}
|
||||
@ -157,8 +155,7 @@ namespace ts {
|
||||
|
||||
/** Works like Array.prototype.find, returning `undefined` if no element satisfying the predicate is found. */
|
||||
export function find<T>(array: T[], predicate: (element: T, index: number) => boolean): T | undefined {
|
||||
const len = array.length;
|
||||
for (let i = 0; i < len; i++) {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
const value = array[i];
|
||||
if (predicate(value, i)) {
|
||||
return value;
|
||||
@ -172,8 +169,7 @@ namespace ts {
|
||||
* This is like `forEach`, but never returns undefined.
|
||||
*/
|
||||
export function findMap<T, U>(array: T[], callback: (element: T, index: number) => U | undefined): U {
|
||||
const len = array.length;
|
||||
for (let i = 0; i < len; i++) {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
const result = callback(array[i], i);
|
||||
if (result) {
|
||||
return result;
|
||||
@ -195,8 +191,7 @@ namespace ts {
|
||||
|
||||
export function indexOf<T>(array: T[], value: T): number {
|
||||
if (array) {
|
||||
const len = array.length;
|
||||
for (let i = 0; i < len; i++) {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
if (array[i] === value) {
|
||||
return i;
|
||||
}
|
||||
@ -206,8 +201,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function indexOfAnyCharCode(text: string, charCodes: number[], start?: number): number {
|
||||
const len = text.length;
|
||||
for (let i = start || 0; i < len; i++) {
|
||||
for (let i = start || 0; i < text.length; i++) {
|
||||
if (contains(charCodes, text.charCodeAt(i))) {
|
||||
return i;
|
||||
}
|
||||
|
||||
@ -7404,8 +7404,7 @@ namespace ts {
|
||||
if (position >= array.pos && position < array.end) {
|
||||
// position was in this array. Search through this array to see if we find a
|
||||
// viable element.
|
||||
const n = array.length;
|
||||
for (let i = 0; i < n; i++) {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
const child = array[i];
|
||||
if (child) {
|
||||
if (child.pos === position) {
|
||||
|
||||
@ -696,8 +696,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
// update fileName -> file mapping
|
||||
const len = newSourceFiles.length;
|
||||
for (let i = 0; i < len; i++) {
|
||||
for (let i = 0; i < newSourceFiles.length; i++) {
|
||||
filesByName.set(filePaths[i], newSourceFiles[i]);
|
||||
}
|
||||
|
||||
|
||||
@ -766,8 +766,7 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
const n = name.length;
|
||||
for (let i = 1; i < n; i++) {
|
||||
for (let i = 1; i < name.length; i++) {
|
||||
if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -344,8 +344,7 @@ namespace Utils {
|
||||
|
||||
assert.equal(array1.length, array2.length, "array1.length !== array2.length");
|
||||
|
||||
const n = array1.length;
|
||||
for (let i = 0; i < n; i++) {
|
||||
for (let i = 0; i < array1.length; i++) {
|
||||
const d1 = array1[i];
|
||||
const d2 = array2[i];
|
||||
|
||||
@ -401,8 +400,7 @@ namespace Utils {
|
||||
assert.equal(array1.end, array2.end, "array1.end !== array2.end");
|
||||
assert.equal(array1.length, array2.length, "array1.length !== array2.length");
|
||||
|
||||
const n = array1.length;
|
||||
for (let i = 0; i < n; i++) {
|
||||
for (let i = 0; i < array1.length; i++) {
|
||||
assertStructuralEquals(array1[i], array2[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,8 +28,7 @@ namespace ts {
|
||||
const diagnostics2 = file2.parseDiagnostics;
|
||||
|
||||
assert.equal(diagnostics1.length, diagnostics2.length, "diagnostics1.length !== diagnostics2.length");
|
||||
const n = diagnostics1.length;
|
||||
for (let i = 0; i < n; i++) {
|
||||
for (let i = 0; i < diagnostics1.length; i++) {
|
||||
const d1 = diagnostics1[i];
|
||||
const d2 = diagnostics2[i];
|
||||
|
||||
|
||||
@ -502,8 +502,7 @@ describe("PatternMatcher", function () {
|
||||
function assertArrayEquals<T>(array1: T[], array2: T[]) {
|
||||
assert.equal(array1.length, array2.length);
|
||||
|
||||
const n = array1.length;
|
||||
for (let i = 0; i < n; i++) {
|
||||
for (let i = 0; i < array1.length; i++) {
|
||||
assert.equal(array1[i], array2[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -307,8 +307,7 @@ and grew 1cm per day`;
|
||||
|
||||
it("Start pos from line", () => {
|
||||
for (let i = 0; i < iterationCount; i++) {
|
||||
const llen = lines.length;
|
||||
for (let j = 0; j < llen; j++) {
|
||||
for (let j = 0; j < lines.length; j++) {
|
||||
const lineInfo = lineIndex.lineNumberToInfo(j + 1);
|
||||
const lineIndexOffset = lineInfo.offset;
|
||||
const lineMapOffset = lineMap[j];
|
||||
|
||||
@ -113,8 +113,7 @@ namespace ts.server {
|
||||
if (len > 1) {
|
||||
let insertedNodes = <LineCollection[]>new Array(len - 1);
|
||||
let startNode = <LineCollection>leafNode;
|
||||
const n = lines.length
|
||||
for (let i = 1; i < n; i++) {
|
||||
for (let i = 1; i < lines.length; i++) {
|
||||
insertedNodes[i - 1] = new LineLeaf(lines[i]);
|
||||
}
|
||||
let pathIndex = this.startPath.length - 2;
|
||||
@ -470,8 +469,7 @@ namespace ts.server {
|
||||
load(lines: string[]) {
|
||||
if (lines.length > 0) {
|
||||
const leaves: LineLeaf[] = [];
|
||||
const len = lines.length;
|
||||
for (let i = 0; i < len; i++) {
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
leaves[i] = new LineLeaf(lines[i]);
|
||||
}
|
||||
this.root = LineIndex.buildTreeFromBottom(leaves);
|
||||
|
||||
@ -409,8 +409,8 @@ namespace ts.server {
|
||||
function parseLoggingEnvironmentString(logEnvStr: string): LogOptions {
|
||||
const logEnv: LogOptions = { logToFile: true };
|
||||
const args = logEnvStr.split(" ");
|
||||
const len = args.length;
|
||||
for (let i = 0; i < (len - 1); i += 2) {
|
||||
const len = args.length - 1;
|
||||
for (let i = 0; i < len; i += 2) {
|
||||
const option = args[i];
|
||||
const value = args[i + 1];
|
||||
if (option && value) {
|
||||
|
||||
@ -71,8 +71,7 @@ namespace ts {
|
||||
const dense = classifications.spans;
|
||||
let lastEnd = 0;
|
||||
|
||||
const n = dense.length;
|
||||
for (let i = 0; i < n; i += 3) {
|
||||
for (let i = 0; i < dense.length; i += 3) {
|
||||
const start = dense[i];
|
||||
const length = dense[i + 1];
|
||||
const type = <ClassificationType>dense[i + 2];
|
||||
@ -607,8 +606,7 @@ namespace ts {
|
||||
const dense = classifications.spans;
|
||||
const result: ClassifiedSpan[] = [];
|
||||
|
||||
const n = dense.length;
|
||||
for (let i = 0; i < n; i += 3) {
|
||||
for (let i = 0; i < dense.length; i += 3) {
|
||||
result.push({
|
||||
textSpan: createTextSpan(dense[i], dense[i + 1]),
|
||||
classificationType: getClassificationTypeName(dense[i + 2])
|
||||
|
||||
@ -950,8 +950,7 @@ namespace ts.formatting {
|
||||
|
||||
// shift all parts on the delta size
|
||||
const delta = indentation - nonWhitespaceColumnInFirstPart.column;
|
||||
const len = parts.length;
|
||||
for (let i = startIndex; i < len; i++ , startLine++) {
|
||||
for (let i = startIndex; i < parts.length; i++ , startLine++) {
|
||||
const startLinePos = getStartPositionOfLine(startLine, sourceFile);
|
||||
const nonWhitespaceCharacterAndColumn =
|
||||
i === 0
|
||||
|
||||
@ -76,8 +76,7 @@ namespace ts.JsDoc {
|
||||
*/
|
||||
function forEachUnique<T, U>(array: T[], callback: (element: T, index: number) => U): U {
|
||||
if (array) {
|
||||
const len = array.length;
|
||||
for (let i = 0; i < len; i++) {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
if (indexOf(array, array[i]) === i) {
|
||||
const result = callback(array[i], i);
|
||||
if (result) {
|
||||
@ -171,8 +170,7 @@ namespace ts.JsDoc {
|
||||
const isJavaScriptFile = hasJavaScriptFileExtension(sourceFile.fileName);
|
||||
|
||||
let docParams = "";
|
||||
const numParams = parameters.length;
|
||||
for (let i = 0; i < numParams; i++) {
|
||||
for (let i = 0; i < parameters.length; i++) {
|
||||
const currentName = parameters[i].name;
|
||||
const paramName = currentName.kind === SyntaxKind.Identifier ?
|
||||
(<Identifier>currentName).text :
|
||||
|
||||
@ -528,8 +528,7 @@ namespace ts {
|
||||
|
||||
// Assumes 'value' is already lowercase.
|
||||
function startsWithIgnoringCase(string: string, value: string, start: number): boolean {
|
||||
const n = value.length;
|
||||
for (let i = 0; i < n; i++) {
|
||||
for (let i = 0; i < value.length; i++) {
|
||||
const ch1 = toLowerCase(string.charCodeAt(i + start));
|
||||
const ch2 = value.charCodeAt(i);
|
||||
|
||||
@ -615,8 +614,7 @@ namespace ts {
|
||||
const result: TextSpan[] = [];
|
||||
|
||||
let wordStart = 0;
|
||||
const n = identifier.length;
|
||||
for (let i = 1; i < n; i++) {
|
||||
for (let i = 1; i < identifier.length; i++) {
|
||||
const lastIsDigit = isDigit(identifier.charCodeAt(i - 1));
|
||||
const currentIsDigit = isDigit(identifier.charCodeAt(i));
|
||||
|
||||
|
||||
@ -1793,8 +1793,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
let descriptor: TodoCommentDescriptor = undefined;
|
||||
const n = descriptors.length;
|
||||
for (let i = 0; i < n; i++) {
|
||||
for (let i = 0; i < descriptors.length; i++) {
|
||||
if (matchArray[i + firstDescriptorCaptureIndex]) {
|
||||
descriptor = descriptors[i];
|
||||
}
|
||||
|
||||
@ -1239,8 +1239,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
public unregisterShim(shim: Shim): void {
|
||||
const n = this._shims.length;
|
||||
for (let i = 0; i < n; i++) {
|
||||
for (let i = 0; i < this._shims.length; i++) {
|
||||
if (this._shims[i] === shim) {
|
||||
delete this._shims[i];
|
||||
return;
|
||||
|
||||
@ -765,8 +765,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
const children = n.getChildren();
|
||||
const len = children.length;
|
||||
for (let i = 0; i < len; i++) {
|
||||
for (let i = 0; i < children.length; i++) {
|
||||
const child = children[i];
|
||||
// condition 'position < child.end' checks if child node end after the position
|
||||
// in the example below this condition will be false for 'aaaa' and 'bbbb' and true for 'ccc'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user