From db9f8126db23ba90be62777f26a692c7adbb10d9 Mon Sep 17 00:00:00 2001 From: Robin Rosenberg Date: Mon, 28 Dec 2009 16:54:43 +0100 Subject: Get rid of a duplicate constant for SHA-1 length Since Constants.OBJECT_ID_LENGTH is a compile time constant we can be sure that it will always be inlined. The same goes for the associated constant STR_LEN which is now refactored to the Constant class and given a name better suited for wider use. Change-Id: I03f52131e64edcd0aa74bbbf36e7d42faaf4a698 Signed-off-by: Robin Rosenberg --- .../src/org/eclipse/jgit/lib/AbbreviatedObjectId.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/lib/AbbreviatedObjectId.java') diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/AbbreviatedObjectId.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/AbbreviatedObjectId.java index 13c54201c6..9d9174111b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/AbbreviatedObjectId.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/AbbreviatedObjectId.java @@ -73,7 +73,7 @@ public final class AbbreviatedObjectId { */ public static final AbbreviatedObjectId fromString(final byte[] buf, final int offset, final int end) { - if (end - offset > AnyObjectId.STR_LEN) + if (end - offset > Constants.OBJECT_ID_STRING_LENGTH) throw new IllegalArgumentException("Invalid id"); return fromHexString(buf, offset, end); } @@ -86,7 +86,7 @@ public final class AbbreviatedObjectId { * @return the converted object id. */ public static final AbbreviatedObjectId fromString(final String str) { - if (str.length() > AnyObjectId.STR_LEN) + if (str.length() > Constants.OBJECT_ID_STRING_LENGTH) throw new IllegalArgumentException("Invalid id: " + str); final byte[] b = Constants.encodeASCII(str); return fromHexString(b, 0, b.length); @@ -167,7 +167,7 @@ public final class AbbreviatedObjectId { /** @return true if this ObjectId is actually a complete id. */ public boolean isComplete() { - return length() == AnyObjectId.RAW_LEN * 2; + return length() == Constants.OBJECT_ID_STRING_LENGTH; } /** @return a complete ObjectId; null if {@link #isComplete()} is false */ @@ -231,7 +231,7 @@ public final class AbbreviatedObjectId { * @return string form of the abbreviation, in lower case hexadecimal. */ public final String name() { - final char[] b = new char[AnyObjectId.STR_LEN]; + final char[] b = new char[Constants.OBJECT_ID_STRING_LENGTH]; AnyObjectId.formatHexChar(b, 0, w1); if (nibbles <= 8) -- cgit v1.2.3