@@ -39,9 +39,7 @@ namespace fakes {
39
39
public readFile ( path : string ) {
40
40
try {
41
41
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 ) ;
45
43
}
46
44
catch {
47
45
return undefined ;
@@ -203,6 +201,7 @@ namespace fakes {
203
201
public readonly sys : System ;
204
202
public readonly defaultLibLocation : string ;
205
203
public readonly outputs : documents . TextDocument [ ] = [ ] ;
204
+ private readonly _outputsMap : collections . SortedMap < string , number > ;
206
205
public readonly traces : string [ ] = [ ] ;
207
206
public readonly shouldAssertInvariants = ! Harness . lightMode ;
208
207
@@ -218,6 +217,7 @@ namespace fakes {
218
217
this . _newLine = ts . getNewLineCharacter ( options , ( ) => this . sys . newLine ) ;
219
218
this . _sourceFiles = new collections . SortedMap < string , ts . SourceFile > ( { comparer : sys . vfs . stringComparer , sort : "insertion" } ) ;
220
219
this . _setParentNodes = setParentNodes ;
220
+ this . _outputsMap = new collections . SortedMap ( this . vfs . stringComparer ) ;
221
221
}
222
222
223
223
public get vfs ( ) {
@@ -271,13 +271,11 @@ namespace fakes {
271
271
const document = new documents . TextDocument ( fileName , content ) ;
272
272
document . meta . set ( "fileName" , fileName ) ;
273
273
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 ) ;
276
276
this . outputs . push ( document ) ;
277
277
}
278
- else {
279
- this . outputs [ index ] = document ;
280
- }
278
+ this . outputs [ this . _outputsMap . get ( document . file ) ] = document ;
281
279
}
282
280
283
281
public trace ( s : string ) : void {
0 commit comments