Avoid calling indexOf when checking array element types (#18619)

* Avoid calling `indexOf` when checking array element types

* Add 'indexOfNode' and use it in cases which may handle long lists. (#18635)

* Fix bug where contextual type was not reused if undefined
This commit is contained in:
Andy
2017-09-22 08:49:56 -07:00
committed by GitHub
parent 1a383ec290
commit 7e002aeb7b
4 changed files with 37 additions and 20 deletions

View File

@@ -226,7 +226,7 @@ namespace ts.textChanges {
Debug.fail("node is not a list element");
return this;
}
const index = containingList.indexOf(node);
const index = indexOfNode(containingList, node);
if (index < 0) {
return this;
}
@@ -358,7 +358,7 @@ namespace ts.textChanges {
Debug.fail("node is not a list element");
return this;
}
const index = containingList.indexOf(after);
const index = indexOfNode(containingList, after);
if (index < 0) {
return this;
}

View File

@@ -597,7 +597,7 @@ namespace ts {
}
const children = list.getChildren();
const listItemIndex = indexOf(children, node);
const listItemIndex = indexOfNode(children, node);
return {
listItemIndex,