@@ -39,9 +39,7 @@ namespace fakes {
3939 public readFile ( path : string ) {
4040 try {
4141 const content = this . vfs . readFileSync ( path , "utf8" ) ;
42- return content === undefined ? undefined :
43- vpath . extname ( path ) === ".json" ? utils . removeComments ( utils . removeByteOrderMark ( content ) , utils . CommentRemoval . leadingAndTrailing ) :
44- utils . removeByteOrderMark ( content ) ;
42+ return content === undefined ? undefined : utils . removeByteOrderMark ( content ) ;
4543 }
4644 catch {
4745 return undefined ;
@@ -203,6 +201,7 @@ namespace fakes {
203201 public readonly sys : System ;
204202 public readonly defaultLibLocation : string ;
205203 public readonly outputs : documents . TextDocument [ ] = [ ] ;
204+ private readonly _outputsMap : collections . SortedMap < string , number > ;
206205 public readonly traces : string [ ] = [ ] ;
207206 public readonly shouldAssertInvariants = ! Harness . lightMode ;
208207
@@ -218,6 +217,7 @@ namespace fakes {
218217 this . _newLine = ts . getNewLineCharacter ( options , ( ) => this . sys . newLine ) ;
219218 this . _sourceFiles = new collections . SortedMap < string , ts . SourceFile > ( { comparer : sys . vfs . stringComparer , sort : "insertion" } ) ;
220219 this . _setParentNodes = setParentNodes ;
220+ this . _outputsMap = new collections . SortedMap ( this . vfs . stringComparer ) ;
221221 }
222222
223223 public get vfs ( ) {
@@ -271,13 +271,11 @@ namespace fakes {
271271 const document = new documents . TextDocument ( fileName , content ) ;
272272 document . meta . set ( "fileName" , fileName ) ;
273273 this . vfs . filemeta ( fileName ) . set ( "document" , document ) ;
274- const index = this . outputs . findIndex ( output => this . vfs . stringComparer ( document . file , output . file ) === 0 ) ;
275- if ( index < 0 ) {
274+ if ( ! this . _outputsMap . has ( document . file ) ) {
275+ this . _outputsMap . set ( document . file , this . outputs . length ) ;
276276 this . outputs . push ( document ) ;
277277 }
278- else {
279- this . outputs [ index ] = document ;
280- }
278+ this . outputs [ this . _outputsMap . get ( document . file ) ] = document ;
281279 }
282280
283281 public trace ( s : string ) : void {
0 commit comments