Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion openfoam_residuals/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
Loading