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 10% in PR #274 (skip-formatting-for-large-diffs)
Here’s a much faster rewrite. The main overhead is in the list comprehension, the function call for every line, and building the temporary list (`diff_lines`). Instead, use a generator expression (which avoids building the list in memory) and inline the test logic.
**Explanation of changes:**
- Removed the nested function to avoid repeated function call overhead.
- Converted the list comprehension to a generator expression fed to `sum()`, so only the count is accumulated (no intermediate list).
- Inlined the test logic inside the generator for further speed.
This version will be significantly faster and lower on memory usage, especially for large diff outputs.
If you have profile results after this, you’ll see the difference is dramatic!
0 commit comments