Perf suggestion for crlf handling
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 10.6k
- Forks
- 2.7k
- PR merge metrics
- No merged PRs in 30d
Description
I haven't measured this but....
As long a the crlf filtering is loading the entire blob/file into a buffer, there are some opportunities here for perf gains.
In git_buf_text_is_binary() we examine the entire file. While there we could count the number of CRLFs, and plain LFs and return those sums. We should be able to use those sums in git_buf_text_gather_stats(). Or combine those 2 routines into 1. Then in git_buf_text_lf_to_crlf() add this delta "(count_crlf - count_lf)" as padding to the amount of reserved space in the destination buffer so that the memcpy loop doesn't need to realloc as the file is being converted.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading git_buf_text_is_binary(), git_buf_text_gather_stats(), and git_buf_text_lf_to_crlf() to understand their current buffer and line-ending handling. Measure the existing behavior before evaluating the suggested combined counts and padding; done means conversion avoids unnecessary reallocations without changing the resulting text.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, git
- Domain
- performance
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 43/100