If the object type is a whole object and all we want is the type,
there is no need to skip the length header. The type is already known
and can be returned as-is. Instead skip the length header only for
the two delta formats, where the delta base must itself be scanned.
Change-Id: I87029258e88924b3e5850bdd6c9006a366191d10
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
readFully(pos, ib, 0, 20, curs);
int c = ib[0] & 0xff;
final int type = (c >> 4) & 7;
- int p = 1;
- while ((c & 0x80) != 0)
- c = ib[p++] & 0xff;
switch (type) {
case Constants.OBJ_COMMIT:
return type;
case Constants.OBJ_OFS_DELTA: {
+ int p = 1;
+ while ((c & 0x80) != 0)
+ c = ib[p++] & 0xff;
c = ib[p++] & 0xff;
long ofs = c & 127;
while ((c & 128) != 0) {
}
case Constants.OBJ_REF_DELTA: {
+ int p = 1;
+ while ((c & 0x80) != 0)
+ c = ib[p++] & 0xff;
readFully(pos + p, ib, 0, 20, curs);
pos = findDeltaBase(ObjectId.fromRaw(ib));
continue;