aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorIvan Frade <ifrade@google.com>2022-10-07 14:21:48 -0700
committerIvan Frade <ifrade@google.com>2023-07-14 10:25:20 -0700
commit4d2a003b913edc6981f4f73354c0ad4f52716303 (patch)
tree704ddbda90782f610099b413e9626eda8098102a /org.eclipse.jgit
parent12a4a4ccaadefa7e2dd157ca2bd211ef460b825c (diff)
downloadjgit-4d2a003b913edc6981f4f73354c0ad4f52716303.tar.gz
jgit-4d2a003b913edc6981f4f73354c0ad4f52716303.zip
DfsInserter: populate full size on object insertion
We need the full size of the object to populate the object size index later. Save the size the PackedObjectInfo while adding objects to the pack. Then we don't need to re-read it from the pack at indexing time. Change-Id: I5bd7ad402df60b4637038def8ef7be2ab45faf87
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java15
1 files changed, 9 insertions, 6 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java
index ceb1769dec..5f25905a5b 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java
@@ -129,7 +129,7 @@ public class DfsInserter extends ObjectInserter {
long offset = beginObject(type, len);
packOut.compress.write(data, off, len);
packOut.compress.finish();
- return endObject(id, offset);
+ return endObject(id, offset, len, type);
}
@Override
@@ -148,16 +148,17 @@ public class DfsInserter extends ObjectInserter {
md.update(Constants.encodeASCII(len));
md.update((byte) 0);
- while (0 < len) {
- int n = in.read(buf, 0, (int) Math.min(buf.length, len));
+ long inLength = len;
+ while (0 < inLength) {
+ int n = in.read(buf, 0, (int) Math.min(buf.length, inLength));
if (n <= 0)
throw new EOFException();
md.update(buf, 0, n);
packOut.compress.write(buf, 0, n);
- len -= n;
+ inLength -= n;
}
packOut.compress.finish();
- return endObject(md.toObjectId(), offset);
+ return endObject(md.toObjectId(), offset, len, type);
}
private byte[] insertBuffer(long len) {
@@ -238,10 +239,12 @@ public class DfsInserter extends ObjectInserter {
return offset;
}
- private ObjectId endObject(ObjectId id, long offset) {
+ private ObjectId endObject(ObjectId id, long offset, long inflatedSize, int type) {
PackedObjectInfo obj = new PackedObjectInfo(id);
+ obj.setType(type);
obj.setOffset(offset);
obj.setCRC((int) packOut.crc32.getValue());
+ obj.setFullSize(inflatedSize);
objectList.add(obj);
objectMap.addIfAbsent(obj);
return id;