remove multiple collections for open files

This commit is contained in:
Vladimir Matveev
2016-06-28 17:45:29 -07:00
parent 9bec244469
commit d7bf32270e
5 changed files with 256 additions and 213 deletions

View File

@@ -37,11 +37,37 @@ namespace ts.server {
}
isAttached(project: Project) {
return contains(this.containingProjects, project);
// unrolled for common cases
switch (this.containingProjects.length) {
case 0: return false;
case 1: return this.containingProjects[0] === project;
case 2: return this.containingProjects[0] === project || this.containingProjects[1] === project;
default: return contains(this.containingProjects, project);
}
}
detachFromProject(project: Project) {
removeItemFromSet(this.containingProjects, project);
// unrolled for common cases
switch (this.containingProjects.length) {
case 0:
return;
case 1:
if (this.containingProjects[0] === project) {
this.containingProjects.pop();
}
break;
case 2:
if (this.containingProjects[0] === project) {
this.containingProjects[0] = this.containingProjects.pop();
}
if (this.containingProjects[1] === project) {
this.containingProjects.pop();
}
break;
default:
removeItemFromSet(this.containingProjects, project);
break;
}
}
detachAllProjects() {