Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2015-11-15 01:46:21 +0300
committerCarlos Martín Nieto <cmn@dwim.me>2015-11-28 21:21:51 +0300
commit7132150ddf7a883c1f12a89c2518c1a07c0dc94c (patch)
tree32b101251f51b7c1b753c4ef29bd78ddc5181bec
parente0ab1ca0288db57fabbd63dfb6a0cd27f3acf8b2 (diff)
tree: avoid advancing over the filename multiple times
We've already looked at the filename with `memchr()` and then used `strlen()` to allocate the entry. We already know how much we have to advance to get to the object id, so add the filename length instead of looking at each byte again.
-rw-r--r--src/tree.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/tree.c b/src/tree.c
index bdd17661b..3504452c2 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -414,10 +414,8 @@ int git_tree__parse(void *_tree, git_odb_object *odb_obj)
entry->attr = attr;
}
- while (buffer < buffer_end && *buffer != 0)
- buffer++;
-
- buffer++;
+ /* Advance to the ID just after the path */
+ buffer += entry->filename_len + 1;
git_oid_fromraw(&entry->oid, (const unsigned char *)buffer);
buffer += GIT_OID_RAWSZ;