@@ -275,7 +275,7 @@ namespace ts.server {
275275 removeRoot ( info : ScriptInfo ) {
276276 if ( this . filenameToScript . contains ( info . path ) ) {
277277 this . filenameToScript . remove ( info . path ) ;
278- this . roots = copyListRemovingItem ( info , this . roots ) ;
278+ unorderedRemoveItem ( this . roots , info ) ;
279279 this . resolvedModuleNames . remove ( info . path ) ;
280280 this . resolvedTypeReferenceDirectives . remove ( info . path ) ;
281281 }
@@ -585,16 +585,6 @@ namespace ts.server {
585585 project ?: Project ;
586586 }
587587
588- function copyListRemovingItem < T > ( item : T , list : T [ ] ) {
589- const copiedList : T [ ] = [ ] ;
590- for ( let i = 0 , len = list . length ; i < len ; i ++ ) {
591- if ( list [ i ] != item ) {
592- copiedList . push ( list [ i ] ) ;
593- }
594- }
595- return copiedList ;
596- }
597-
598588 /**
599589 * This helper funciton processes a list of projects and return the concatenated, sortd and deduplicated output of processing each project.
600590 */
@@ -880,7 +870,7 @@ namespace ts.server {
880870 project . directoryWatcher . close ( ) ;
881871 forEachProperty ( project . directoriesWatchedForWildcards , watcher => { watcher . close ( ) ; } ) ;
882872 delete project . directoriesWatchedForWildcards ;
883- this . configuredProjects = copyListRemovingItem ( project , this . configuredProjects ) ;
873+ unorderedRemoveItem ( this . configuredProjects , project ) ;
884874 }
885875 else {
886876 for ( const directory of project . directoriesWatchedForTsconfig ) {
@@ -892,7 +882,7 @@ namespace ts.server {
892882 delete project . projectService . directoryWatchersForTsconfig [ directory ] ;
893883 }
894884 }
895- this . inferredProjects = copyListRemovingItem ( project , this . inferredProjects ) ;
885+ unorderedRemoveItem ( this . inferredProjects , project ) ;
896886 }
897887
898888 const fileNames = project . getFileNames ( ) ;
@@ -1017,7 +1007,7 @@ namespace ts.server {
10171007 }
10181008 }
10191009 else {
1020- this . openFilesReferenced = copyListRemovingItem ( info , this . openFilesReferenced ) ;
1010+ unorderedRemoveItem ( this . openFilesReferenced , info ) ;
10211011 }
10221012 info . close ( ) ;
10231013 }
@@ -1524,13 +1514,13 @@ namespace ts.server {
15241514 // openFileRoots or openFileReferenced.
15251515 if ( info . isOpen ) {
15261516 if ( this . openFileRoots . indexOf ( info ) >= 0 ) {
1527- this . openFileRoots = copyListRemovingItem ( info , this . openFileRoots ) ;
1517+ unorderedRemoveItem ( this . openFileRoots , info ) ;
15281518 if ( info . defaultProject && ! info . defaultProject . isConfiguredProject ( ) ) {
15291519 this . removeProject ( info . defaultProject ) ;
15301520 }
15311521 }
15321522 if ( this . openFilesReferenced . indexOf ( info ) >= 0 ) {
1533- this . openFilesReferenced = copyListRemovingItem ( info , this . openFilesReferenced ) ;
1523+ unorderedRemoveItem ( this . openFilesReferenced , info ) ;
15341524 }
15351525 this . openFileRootsConfigured . push ( info ) ;
15361526 info . defaultProject = project ;
0 commit comments