diff options
author | Junio C Hamano <gitster@pobox.com> | 2014-07-02 12:53:02 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-07-02 12:53:02 -0700 |
commit | 8061ae8b4618d69a67ff6cfb687d7044964d4b04 (patch) | |
tree | fd75c5ef40caf10107f15e320bbb9501017ba695 /sha1_name.c | |
parent | enums: remove trailing ',' after last item in enum (diff) | |
parent | reuse cached commit buffer when parsing signatures (diff) | |
download | tgif-8061ae8b4618d69a67ff6cfb687d7044964d4b04.tar.xz |
Merge branch 'jk/commit-buffer-length'
Move "commit->buffer" out of the in-core commit object and keep
track of their lengths. Use this to optimize the code paths to
validate GPG signatures in commit objects.
* jk/commit-buffer-length:
reuse cached commit buffer when parsing signatures
commit: record buffer length in cache
commit: convert commit->buffer to a slab
commit-slab: provide a static initializer
use get_commit_buffer everywhere
convert logmsg_reencode to get_commit_buffer
use get_commit_buffer to avoid duplicate code
use get_cached_commit_buffer where appropriate
provide helpers to access the commit buffer
provide a helper to set the commit buffer
provide a helper to free commit buffer
sequencer: use logmsg_reencode in get_message
logmsg_reencode: return const buffer
do not create "struct commit" with xcalloc
commit: push commit_index update into alloc_commit_node
alloc: include any-object allocations in alloc_report
replace dangerous uses of strbuf_attach
commit_tree: take a pointer/len pair rather than a const strbuf
Diffstat (limited to 'sha1_name.c')
-rw-r--r-- | sha1_name.c | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/sha1_name.c b/sha1_name.c index 2b6322fad0..c2c938c4e1 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -862,27 +862,17 @@ static int get_sha1_oneline(const char *prefix, unsigned char *sha1, commit_list_insert(l->item, &backup); } while (list) { - char *p, *to_free = NULL; + const char *p, *buf; struct commit *commit; - enum object_type type; - unsigned long size; int matches; commit = pop_most_recent_commit(&list, ONELINE_SEEN); if (!parse_object(commit->object.sha1)) continue; - if (commit->buffer) - p = commit->buffer; - else { - p = read_sha1_file(commit->object.sha1, &type, &size); - if (!p) - continue; - to_free = p; - } - - p = strstr(p, "\n\n"); + buf = get_commit_buffer(commit, NULL); + p = strstr(buf, "\n\n"); matches = p && !regexec(®ex, p + 2, 0, NULL, 0); - free(to_free); + unuse_commit_buffer(commit, buf); if (matches) { hashcpy(sha1, commit->object.sha1); |