File tree Expand file tree Collapse file tree 1 file changed +5
-7
lines changed
Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change 11using System ;
2+ using System . Collections . Concurrent ;
23using System . Collections . Generic ;
34using System . IO ;
45using System . Linq ;
78namespace Microsoft . Dafny ;
89
910public class DafnyConsolePrinter : ConsolePrinter {
10- private readonly Dictionary < string , List < string > > fsCache = new ( ) ;
11+ private readonly ConcurrentDictionary < string , List < string > > fsCache = new ( ) ;
1112 public List < ( Implementation , VerificationResult ) > VerificationResults { get ; } = new ( ) ;
1213
1314 private string GetFileLine ( string filename , int lineIndex ) {
14- List < string > lines ;
15- if ( ! fsCache . ContainsKey ( filename ) ) {
15+ List < string > lines = fsCache . GetOrAdd ( filename , key => {
1616 try {
1717 // Note: This is not guaranteed to be the same file that Dafny parsed. To ensure that, Dafny should keep
1818 // an in-memory version of each file it parses.
1919 lines = File . ReadLines ( filename ) . ToList ( ) ;
2020 } catch ( Exception ) {
2121 lines = new List < string > ( ) ;
2222 }
23- fsCache . Add ( filename , lines ) ;
24- } else {
25- lines = fsCache [ filename ] ;
26- }
23+ return lines ;
24+ } ) ;
2725 if ( 0 <= lineIndex && lineIndex < lines . Count ) {
2826 return lines [ lineIndex ] ;
2927 }
You can’t perform that action at this time.
0 commit comments