You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
⚡️ Speed up function get_diff_lines_count by 15% in PR #274 (skip-formatting-for-large-diffs)
Here is an optimized version of your program.
Key Improvements.
- Avoids splitting all lines and list allocation; instead, iterates only as needed and sums matches (saves both memory and runtime).
- Eliminates the inner function and replaces it with a fast inline check.
**Why this is faster:**
- Uses a simple for-loop instead of building a list.
- Checks first character directly—less overhead than calling `startswith` multiple times.
- Skips the closure.
- No intermediate list storage.
The function result and behavior are identical.
0 commit comments