git_index_find() in index_insert() is useless if replace is not requested (append). Do not call it in this case. It speedup git_index_append() *dramatically* on large indexes. $ cat index_test.c int main(int argc, char **argv) { git_index *index; git_repository *repo; git_odb *odb; struct git_index_entry entry; git_oid tree_oid; char tree_hex[41]; int i; git_repository_init(&repo, "/tmp/myrepo", 0); odb = git_repository_database(repo); git_repository_index(&index, repo); memset(&entry, 0, sizeof(entry)); git_odb_write(&entry.oid, odb, "", 0, GIT_OBJ_BLOB); entry.path = "test.file"; for (i = 0; i < 50000; i++) git_index_append2(index, &entry); git_tree_create_fromindex(&tree_oid, index); git_oid_fmt(tree_hex, &tree_oid); tree_hex[40] = '\0'; printf("tree: %s\n", tree_hex); git_index_free(index); git_repository_free(repo); return 0; } Before: $ time ./index_test tree: 43f73659c43b651588cc81459d9e25b08721b95d ./index_test 151.19s user 0.05s system 99% cpu 2:31.78 total After: $ time ./index_test tree: 43f73659c43b651588cc81459d9e25b08721b95d ./index_test 0.05s user 0.00s system 94% cpu 0.059 total About 2573 times speedup on this test :) Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Name |
Last commit
|
Last update |
---|---|---|
.. | ||
ppc | Loading commit data... | |
unix | Loading commit data... | |
win32 | Loading commit data... | |
blob.c | Loading commit data... | |
blob.h | Loading commit data... | |
bswap.h | Loading commit data... | |
cache.c | Loading commit data... | |
cache.h | Loading commit data... | |
cc-compat.h | Loading commit data... | |
commit.c | Loading commit data... | |
commit.h | Loading commit data... | |
common.h | Loading commit data... | |
config.c | Loading commit data... | |
config.h | Loading commit data... | |
config_file.c | Loading commit data... | |
delta-apply.c | Loading commit data... | |
delta-apply.h | Loading commit data... | |
dir.h | Loading commit data... | |
errors.c | Loading commit data... | |
filebuf.c | Loading commit data... | |
filebuf.h | Loading commit data... | |
fileops.c | Loading commit data... | |
fileops.h | Loading commit data... | |
fnmatch.c | Loading commit data... | |
fnmatch.h | Loading commit data... | |
hash.c | Loading commit data... | |
hash.h | Loading commit data... | |
hashtable.c | Loading commit data... | |
hashtable.h | Loading commit data... | |
index.c | Loading commit data... | |
index.h | Loading commit data... | |
map.h | Loading commit data... | |
netops.c | Loading commit data... | |
netops.h | Loading commit data... | |
object.c | Loading commit data... | |
odb.c | Loading commit data... | |
odb.h | Loading commit data... | |
odb_loose.c | Loading commit data... | |
odb_pack.c | Loading commit data... | |
oid.c | Loading commit data... | |
path.c | Loading commit data... | |
path.h | Loading commit data... | |
pkt.c | Loading commit data... | |
posix.c | Loading commit data... | |
posix.h | Loading commit data... | |
pqueue.c | Loading commit data... | |
pqueue.h | Loading commit data... | |
refs.c | Loading commit data... | |
refs.h | Loading commit data... | |
refspec.c | Loading commit data... | |
refspec.h | Loading commit data... | |
remote.c | Loading commit data... | |
remote.h | Loading commit data... | |
repository.c | Loading commit data... | |
repository.h | Loading commit data... | |
revwalk.c | Loading commit data... | |
sha1.c | Loading commit data... | |
sha1.h | Loading commit data... | |
sha1_lookup.c | Loading commit data... | |
sha1_lookup.h | Loading commit data... | |
signature.c | Loading commit data... | |
signature.h | Loading commit data... | |
t03-data.h | Loading commit data... | |
tag.c | Loading commit data... | |
tag.h | Loading commit data... | |
thread-utils.c | Loading commit data... | |
thread-utils.h | Loading commit data... | |
transport.c | Loading commit data... | |
transport.h | Loading commit data... | |
transport_git.c | Loading commit data... | |
transport_local.c | Loading commit data... | |
tree.c | Loading commit data... | |
tree.h | Loading commit data... | |
util.c | Loading commit data... | |
util.h | Loading commit data... | |
vector.c | Loading commit data... | |
vector.h | Loading commit data... |