diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2014-02-05 16:01:54 +0400 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2014-02-05 17:31:13 +0400 |
commit | a6563619e98437a99ff49eef590f62dbb1584358 (patch) | |
tree | b50076efb5ee875acfd29157dcdcceecec4890c3 /src/util.h | |
parent | d60064132aa0ffe2bb7a02716b054b0456947e77 (diff) |
commit: faster parsing
The current code issues a lot of strncmp() calls in order to check for
the end of the header, simply in order to copy it and start going
through it again. These are a lot of calls for something we can check as
we go along. Knowing the amount of parents beforehand to reduce
allocations in extreme cases does not make up for them.
Instead start parsing immediately and check for the double-newline after
each header field, leaving the raw_header allocation for the end, which
lets us go through the header once and reduces the amount of strncmp()
calls significantly.
In unscientific testing, this has reduced a shortlog-like usage (walking
though the whole history of a branch and extracting data from the
commits) of git.git from ~830ms to ~700ms and makes the time we spend in
strncmp() negligible.
Diffstat (limited to 'src/util.h')
0 files changed, 0 insertions, 0 deletions