summaryrefslogtreecommitdiff
path: root/include/git2
diff options
context:
space:
mode:
authorKirill A. Shutemov <kirill@shutemov.name>2011-06-30 23:22:42 +0300
committerKirill A. Shutemov <kirill@shutemov.name>2011-07-05 17:52:39 +0300
commit8cc16e29e88a02e26b16da66aca6fa589831b76c (patch)
treed613ce9e40f03bcd5974a5f5b2c5994cb6f2788d /include/git2
parent178376025cc70cc8da3ca58699717f2cc8e495a7 (diff)
downloadlibgit2-8cc16e29e88a02e26b16da66aca6fa589831b76c.tar.gz
index: speedup git_index_append()/git_index_append2()
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>
Diffstat (limited to 'include/git2')
0 files changed, 0 insertions, 0 deletions