From 11c393a1d45db23edb79542fadb301b96498ce05 Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Fri, 8 May 2015 11:04:27 +0200 Subject: [PATCH] Do not concatenate strings as arguments to StringBuilder.append() That more or less defeats the purpose of using a StringBuilder. Change-Id: I519f7bf1c9b6670e63c3714210f834ee845dc69f Signed-off-by: Sebastian Schuberth --- .../jgit/internal/storage/pack/BinaryDelta.java | 16 ++++++++++++---- .../jgit/internal/storage/pack/ObjectToPack.java | 8 ++++---- .../eclipse/jgit/transport/BaseReceivePack.java | 8 +++++--- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/BinaryDelta.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/BinaryDelta.java index 97092cd5eb..2565931e05 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/BinaryDelta.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/BinaryDelta.java @@ -255,8 +255,13 @@ public class BinaryDelta { shift += 7; } while ((c & 0x80) != 0); - if (includeHeader) - r.append("DELTA( BASE=" + baseLen + " RESULT=" + resLen + " )\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + if (includeHeader) { + r.append("DELTA( BASE="); //$NON-NLS-1$ + r.append(baseLen); + r.append(" RESULT="); //$NON-NLS-1$ + r.append(resLen); + r.append(" )\n"); //$NON-NLS-1$ + } while (deltaPtr < delta.length) { final int cmd = delta[deltaPtr++] & 0xff; @@ -285,8 +290,11 @@ public class BinaryDelta { if (copySize == 0) copySize = 0x10000; - r.append(" COPY (" + copyOffset + ", " + copySize + ")\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - + r.append(" COPY ("); //$NON-NLS-1$ + r.append(copyOffset); + r.append(", "); //$NON-NLS-1$ + r.append(copySize); + r.append(")\n"); //$NON-NLS-1$ } else if (cmd != 0) { // Anything else the data is literal within the delta // itself. diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/ObjectToPack.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/ObjectToPack.java index 33cb6af1e2..a0896577f3 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/ObjectToPack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/ObjectToPack.java @@ -390,15 +390,15 @@ public class ObjectToPack extends PackedObjectInfo { if (isEdge()) buf.append(" edge"); if (getDeltaDepth() > 0) - buf.append(" depth=" + getDeltaDepth()); + buf.append(" depth=").append(getDeltaDepth()); if (isDeltaRepresentation()) { if (getDeltaBase() != null) - buf.append(" base=inpack:" + getDeltaBase().name()); + buf.append(" base=inpack:").append(getDeltaBase().name()); else - buf.append(" base=edge:" + getDeltaBaseId().name()); + buf.append(" base=edge:").append(getDeltaBaseId().name()); } if (isWritten()) - buf.append(" offset=" + getOffset()); + buf.append(" offset=").append(getOffset()); buf.append("]"); return buf.toString(); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java index cf6b2fd3d0..36ea647c0c 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java @@ -1461,9 +1461,11 @@ public abstract class BaseReceivePack { case REJECTED_MISSING_OBJECT: if (cmd.getMessage() == null) r.append("missing object(s)"); //$NON-NLS-1$ - else if (cmd.getMessage().length() == Constants.OBJECT_ID_STRING_LENGTH) - r.append("object " + cmd.getMessage() + " missing"); //$NON-NLS-1$ //$NON-NLS-2$ - else + else if (cmd.getMessage().length() == Constants.OBJECT_ID_STRING_LENGTH) { + r.append("object "); //$NON-NLS-1$ + r.append(cmd.getMessage()); + r.append(" missing"); //$NON-NLS-1$ + } else r.append(cmd.getMessage()); break; -- 2.39.5