Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fc43646

Browse files
committed
tree: mark a tree as already sorted
The trees are sorted on-disk, so we don't have to go over them again. This cuts almost a fifth of time spent parsing trees.
1 parent 5d1f31c commit fc43646

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ v0.23 + 1
1313
* You can now set your own user-agent to be sent for HTTP requests by
1414
using the `GIT_OPT_SET_USER_AGENT` with `git_libgit2_opts()`.
1515

16+
* Tree objects are now assumed to be sorted. If a tree is not
17+
correctly formed, it will give bad results. This is the git approach
18+
and cuts a significant amount of time when reading the trees.
19+
1620
### API additions
1721

1822
* `git_config_lock()` has been added, which allow for

src/tree.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,8 @@ int git_tree__parse(void *_tree, git_odb_object *odb_obj)
476476
buffer += GIT_OID_RAWSZ;
477477
}
478478

479-
git_vector_sort(&tree->entries);
479+
/* The tree is sorted by definition. Bad inputs give bad outputs */
480+
tree->entries.flags |= GIT_VECTOR_SORTED;
480481

481482
return 0;
482483
}

0 commit comments

Comments
 (0)