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@xxxxxxxxxxx> --- .../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 -- 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