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

Skip to content

Commit d698929

Browse files
committed
Merge pull request libgit2#3537 from libgit2/cmn/tree-is-sorted
tree: mark a tree as already sorted
2 parents a3dc419 + fc43646 commit d698929

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)