From 7ecd65221eb4810204aad203fe0eff73df3142bd Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Sat, 7 May 2022 09:16:51 +0300 Subject: [PATCH] v.util: support -d trace_cached_read_source_file --- vlib/v/util/util.v | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/vlib/v/util/util.v b/vlib/v/util/util.v index e2d49d1769..0178ef749d 100644 --- a/vlib/v/util/util.v +++ b/vlib/v/util/util.v @@ -294,6 +294,9 @@ pub fn cached_read_source_file(path string) ?string { cache = &SourceCache{} } + $if trace_cached_read_source_file ? { + println('cached_read_source_file $path') + } if path.len == 0 { unsafe { cache.sources.free() } unsafe { free(cache) } @@ -304,9 +307,15 @@ pub fn cached_read_source_file(path string) ?string { // eprintln('>> cached_read_source_file path: $path') if res := cache.sources[path] { // eprintln('>> cached') + $if trace_cached_read_source_file_cached ? { + println('cached_read_source_file cached $path') + } return res } // eprintln('>> not cached | cache.sources.len: $cache.sources.len') + $if trace_cached_read_source_file_not_cached ? { + println('cached_read_source_file not cached $path') + } raw_text := os.read_file(path) or { return error('failed to open $path') } res := skip_bom(raw_text) cache.sources[path] = res