git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Shawn O. Pearce" <spearce@spearce.org>
To: Robin Rosenberg <robin.rosenberg@dewire.com>
Cc: Marek Zawirski <marek.zawirski@gmail.com>,
	Daniel Cheng <j16sdiz+freenet@gmail.com>,
	git@vger.kernel.org
Subject: [JGIT PATCH 4/5] Write the pack header in one shot
Date: Wed, 25 Mar 2009 18:21:54 -0700	[thread overview]
Message-ID: <1238030515-31768-4-git-send-email-spearce@spearce.org> (raw)
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 <spearce@spearce.org>
---
 .../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

  reply	other threads:[~2009-03-26  1:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-26  1:21 [JGIT PATCH 1/5] Remove dead/unused reset method from CountingOutputStream Shawn O. Pearce
2009-03-26  1:21 ` [JGIT PATCH 2/5] Implement CRC32 computation during PackWriter Shawn O. Pearce
2009-03-26  1:21   ` [JGIT PATCH 3/5] Test case for pack index CRC32 when written by PackWriter Shawn O. Pearce
2009-03-26  1:21     ` Shawn O. Pearce [this message]
2009-03-26  1:21       ` [JGIT PATCH 5/5] Use Deflater directly in PackWriter Shawn O. Pearce
2009-03-26 15:35     ` [JGIT PATCH 3/5] Test case for pack index CRC32 when written by PackWriter Daniel Cheng
2009-03-26 15:35     ` Daniel Cheng
2009-03-27  8:11 ` patch series starting with [JGIT PATCH 1/5] Remove dead/unused reset method from CountingOutputStream Robin Rosenberg
2009-03-27 14:51   ` Shawn O. Pearce
2009-03-27 14:55   ` Shawn O. Pearce
2009-03-27 23:53     ` Robin Rosenberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1238030515-31768-4-git-send-email-spearce@spearce.org \
    --to=spearce@spearce.org \
    --cc=git@vger.kernel.org \
    --cc=j16sdiz+freenet@gmail.com \
    --cc=marek.zawirski@gmail.com \
    --cc=robin.rosenberg@dewire.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).