summaryrefslogtreecommitdiff
path: root/src/odb.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2016-04-22 18:12:09 +0200
committerCarlos Martín Nieto <cmn@dwim.me>2016-04-22 18:12:09 +0200
commit5fe874632df9c70022e2ea47a01876780f8b3d02 (patch)
tree5ae8cb5782df1b75e7cd6ec89c1df2cbb984f01f /src/odb.c
parent1dc449105b329ea4f8ea9982bc2da869d231c04a (diff)
downloadlibgit2-cmn/read-only-size.tar.gz
odb: allow asking for the size alonecmn/read-only-size
Reading a packed object's type can be expensive if it's deeply chained. Allow a caller to skip that part of the lookup if they don't care or know the type through other means.
Diffstat (limited to 'src/odb.c')
-rw-r--r--src/odb.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/odb.c b/src/odb.c
index 890e6e2f8..0c8cf84f0 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -900,11 +900,12 @@ int git_odb__read_header_or_object(
int error = GIT_ENOTFOUND;
git_odb_object *object;
- assert(db && id && out && len_p && type_p);
+ assert(db && id && out && len_p);
if ((object = git_cache_get_raw(odb_cache(db), id)) != NULL) {
*len_p = object->cached.size;
- *type_p = object->cached.type;
+ if (type_p)
+ *type_p = object->cached.type;
*out = object;
return 0;
}