File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
crates/cairo-lang-filesystem/src Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ use std::sync::Arc;
55
66use cairo_lang_utils:: ordered_hash_map:: OrderedHashMap ;
77use cairo_lang_utils:: { LookupIntern , Upcast } ;
8+ use salsa:: Durability ;
89use semver:: Version ;
910use serde:: { Deserialize , Serialize } ;
1011use smol_str:: { SmolStr , ToSmolStr } ;
@@ -313,10 +314,16 @@ fn crate_config(db: &dyn FilesGroup, crt: CrateId) -> Option<CrateConfiguration>
313314
314315fn priv_raw_file_content ( db : & dyn FilesGroup , file : FileId ) -> Option < Arc < str > > {
315316 match file. lookup_intern ( db) {
316- FileLongId :: OnDisk ( path) => match fs:: read_to_string ( path) {
317- Ok ( content) => Some ( content. into ( ) ) ,
318- Err ( _) => None ,
319- } ,
317+ FileLongId :: OnDisk ( path) => {
318+ // This does not result in performance cost due to OS caching and the fact that salsa
319+ // will re-execute only this single query if the file content did not change.
320+ db. salsa_runtime ( ) . report_synthetic_read ( Durability :: LOW ) ;
321+
322+ match fs:: read_to_string ( path) {
323+ Ok ( content) => Some ( content. into ( ) ) ,
324+ Err ( _) => None ,
325+ }
326+ }
320327 FileLongId :: Virtual ( virt) => Some ( virt. content ) ,
321328 FileLongId :: External ( external_id) => Some ( db. ext_as_virtual ( external_id) . content ) ,
322329 }
You can’t perform that action at this time.
0 commit comments