[JGIT PATCH 4/5] Write the pack header in one shot

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Instead of making 3 individual write calls of 4 bytes each, write
the entire header as a single 12 byte buffer.  Its also a little
bit easier to follow the final code, that these items appear at
the 0/4/8 offsets within the 12 byte long header.

Signed-off-by: Shawn O. Pearce <spearce@xxxxxxxxxxx>
---
 .../src/org/spearce/jgit/lib/PackWriter.java       |   11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java b/org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java
index cfec35c..2f34255 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java
@@ -644,13 +644,10 @@ private void selectObjectReuseForObject(final ObjectToPack otp,
 	}
 
 	private void writeHeader() throws IOException {
-		out.write(Constants.PACK_SIGNATURE);
-
-		NB.encodeInt32(buf, 0, PACK_VERSION_GENERATED);
-		out.write(buf, 0, 4);
-
-		NB.encodeInt32(buf, 0, getObjectsNumber());
-		out.write(buf, 0, 4);
+		System.arraycopy(Constants.PACK_SIGNATURE, 0, buf, 0, 4);
+		NB.encodeInt32(buf, 4, PACK_VERSION_GENERATED);
+		NB.encodeInt32(buf, 8, getObjectsNumber());
+		out.write(buf, 0, 12);
 	}
 
 	private void writeObjects() throws IOException {
-- 
1.6.2.1.471.g682837

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux