diff --git a/openfoam_residuals/filesystem.py b/openfoam_residuals/filesystem.py index 6392cc2..7fd1156 100644 --- a/openfoam_residuals/filesystem.py +++ b/openfoam_residuals/filesystem.py @@ -168,7 +168,10 @@ def _parse_openfoam_log(file: Path) -> tuple[pd.DataFrame, pd.Series]: with file.open(encoding="utf-8") as f: for line in f: - if _LOG_TIME_RE.match(line): + # ⚡ Bolt: Fast substring checks before expensive regex matches. + # `in` is implemented in C and highly optimized, bypassing the + # regex engine entirely for the vast majority of log lines. + if "Time =" in line and _LOG_TIME_RE.match(line): if current_row: rows.append(current_row) indices.append(time_step) @@ -179,6 +182,9 @@ def _parse_openfoam_log(file: Path) -> tuple[pd.DataFrame, pd.Series]: if current_row is None: continue + if "Solving for" not in line: + continue + solve_match = _LOG_SOLVE_RE.match(line) if solve_match is None: continue