From: "Shawn O. Pearce" <spearce@spearce.org>
To: Robin Rosenberg <robin.rosenberg@dewire.com>,
Marek Zawirski <marek.zawirski@gmail.com>
Cc: git@vger.kernel.org
Subject: [JGIT PATCH 4/4] Use a singleton for the NullProgressMonitor implementation
Date: Wed, 9 Jul 2008 00:15:31 -0400 [thread overview]
Message-ID: <1215576931-4174-5-git-send-email-spearce@spearce.org> (raw)
In-Reply-To: <1215576931-4174-4-git-send-email-spearce@spearce.org>
No reason to create a new instance every time we need to shove
a null monitor into a variable because someone passed us null.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
.../org/spearce/jgit/lib/NullProgressMonitor.java | 3 +++
.../src/org/spearce/jgit/util/TemporaryBuffer.java | 2 +-
2 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/NullProgressMonitor.java b/org.spearce.jgit/src/org/spearce/jgit/lib/NullProgressMonitor.java
index de75b90..191dc00 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/NullProgressMonitor.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/NullProgressMonitor.java
@@ -42,6 +42,9 @@ package org.spearce.jgit.lib;
* A NullProgressMonitor does not report progress anywhere.
*/
public class NullProgressMonitor implements ProgressMonitor {
+ /** Immutable instance of a null progress monitor. */
+ public static final NullProgressMonitor INSTANCE = new NullProgressMonitor();
+
public void start(int totalTasks) {
// Do not report.
}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/util/TemporaryBuffer.java b/org.spearce.jgit/src/org/spearce/jgit/util/TemporaryBuffer.java
index 20db580..d597c38 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/util/TemporaryBuffer.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/util/TemporaryBuffer.java
@@ -200,7 +200,7 @@ public class TemporaryBuffer extends OutputStream {
public void writeTo(final OutputStream os, ProgressMonitor pm)
throws IOException {
if (pm == null)
- pm = new NullProgressMonitor();
+ pm = NullProgressMonitor.INSTANCE;
if (blocks != null) {
// Everything is in core so we can stream directly to the output.
//
--
1.5.6.74.g8a5e
prev parent reply other threads:[~2008-07-09 4:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-09 4:15 [JGIT PATCH 0/4] Misc. push transport fixes Shawn O. Pearce
2008-07-09 4:15 ` [JGIT PATCH 1/4] Avoid deadlock while fetching from local repository Shawn O. Pearce
2008-07-09 4:15 ` [JGIT PATCH 2/4] Fix pushing of annotated tags to actually include the tag object Shawn O. Pearce
2008-07-09 4:15 ` [JGIT PATCH 3/4] Automatically initialize a new dumb repository during push Shawn O. Pearce
2008-07-09 4:15 ` Shawn O. Pearce [this message]
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=1215576931-4174-5-git-send-email-spearce@spearce.org \
--to=spearce@spearce.org \
--cc=git@vger.kernel.org \
--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).