From: Shawn O. Pearce Date: Thu, 26 Mar 2009 01:21:54 GMT Subject: [JGIT PATCH 4/5] Write the pack header in one shot Message-ID: <1238030515-31768-4-git-send-email-spearce@spearce.org> In-Reply-To: <1238030515-31768-3-git-send-email-spearce@spearce.org> 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 --- .../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