Commit e8266ea
committed
refactor: extract atomic writer, add typed errors, optimize fuzzy match and patch parsing
- Move writeFileAtomic into src/write-file-atomic.ts and drop the __testWriteFileAtomic production export; tests now import the helper directly.
- Introduce PatchParseError and PatchApplicationError so callers can distinguish parsing failures from application failures.
- Precompute trimmed/normalized line and pattern arrays once per fuzz pass instead of re-trimming for every candidate position (O(n*p) -> O(n+p) trims).
- Parse the patch once in execute() and thread the parsed hunks through preview, totalOperations, and applyPatchDetailed instead of re-parsing three times.
- Use Set lookups for mustReadFiles filtering and format mustReadText directly from the array instead of join/split round trips.
- Replace the duplicate ENOENT predicate with the existing hasErrorCode helper.
- Add regression tests pinning parse errors, perf-equivalent fuzzy matches, and the atomic writer entry point.1 parent f1a95ea commit e8266ea
3 files changed
Lines changed: 295 additions & 121 deletions
0 commit comments