Skip to content

Commit 5ab7ec3

Browse files
committed
fix: use read_file_cached instead of raw disk read for JS/TS source
The --file path was calling file.read_text() directly even though find_all_functions_in_file() already primed the discovery cache. Now uses read_file_cached() to hit the cache with zero disk I/O.
1 parent 429718d commit 5ab7ec3

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

codeflash/discovery/functions_to_optimize.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,13 +262,13 @@ def get_functions_to_optimize(
262262
console.rule()
263263
file = Path(file) if isinstance(file, str) else file
264264
functions = find_all_functions_in_file(file)
265-
# Pre-read JS/TS file content once to avoid redundant disk reads in export checks
265+
# Source already cached by find_all_functions_in_file above
266266
_js_ts_source: str | None = None
267267
if only_get_this_function is not None and is_language_supported(file):
268268
_lang = get_language_support(file)
269269
if _lang.language in (Language.JAVASCRIPT, Language.TYPESCRIPT):
270-
with contextlib.suppress(OSError):
271-
_js_ts_source = file.read_text(encoding="utf-8")
270+
with contextlib.suppress(Exception):
271+
_js_ts_source = read_file_cached(file)
272272
if only_get_this_function is not None:
273273
split_function = only_get_this_function.split(".")
274274
if len(split_function) > 2:

0 commit comments

Comments
 (0)