private int mask(int word, int v) { return mask(nibbles, word, v); }
/** * Return an abbreviation (prefix) of this object SHA-1. * <p> * This implementation does not guarantee uniqueness. Callers should instead * use * {@link org.eclipse.jgit.lib.ObjectReader#abbreviate(AnyObjectId, int)} to * obtain a unique abbreviation within the scope of a particular object * database. * * @param len * length of the abbreviated string. * @return SHA-1 abbreviation. */ public AbbreviatedObjectId abbreviate(int len) { final int a = AbbreviatedObjectId.mask(len, 1, w1); final int b = AbbreviatedObjectId.mask(len, 2, w2); final int c = AbbreviatedObjectId.mask(len, 3, w3); final int d = AbbreviatedObjectId.mask(len, 4, w4); final int e = AbbreviatedObjectId.mask(len, 5, w5); return new AbbreviatedObjectId(len, a, b, c, d, e); }
/** * Compares this abbreviation to a full object id. * * @param other * the other object id. * @return <0 if this abbreviation names an object that is less than * <code>other</code>; 0 if this abbreviation exactly matches the * first {@link #length()} digits of <code>other.name()</code>; * >0 if this abbreviation names an object that is after * <code>other</code>. */ public final int prefixCompare(AnyObjectId other) { int cmp; cmp = NB.compareUInt32(w1, mask(1, other.w1)); if (cmp != 0) return cmp; cmp = NB.compareUInt32(w2, mask(2, other.w2)); if (cmp != 0) return cmp; cmp = NB.compareUInt32(w3, mask(3, other.w3)); if (cmp != 0) return cmp; cmp = NB.compareUInt32(w4, mask(4, other.w4)); if (cmp != 0) return cmp; return NB.compareUInt32(w5, mask(5, other.w5)); }
/** * Compare this abbreviation to a network-byte-order ObjectId. * * @param bs * array containing the other ObjectId in network byte order. * @param p * position within {@code bs} to start the compare at. At least 5 * ints, starting at this position are required. * @return <0 if this abbreviation names an object that is less than * <code>other</code>; 0 if this abbreviation exactly matches the * first {@link #length()} digits of <code>other.name()</code>; * >0 if this abbreviation names an object that is after * <code>other</code>. */ public final int prefixCompare(int[] bs, int p) { int cmp; cmp = NB.compareUInt32(w1, mask(1, bs[p])); if (cmp != 0) return cmp; cmp = NB.compareUInt32(w2, mask(2, bs[p + 1])); if (cmp != 0) return cmp; cmp = NB.compareUInt32(w3, mask(3, bs[p + 2])); if (cmp != 0) return cmp; cmp = NB.compareUInt32(w4, mask(4, bs[p + 3])); if (cmp != 0) return cmp; return NB.compareUInt32(w5, mask(5, bs[p + 4])); }
/** * Compare this abbreviation to a network-byte-order ObjectId. * * @param bs * array containing the other ObjectId in network byte order. * @param p * position within {@code bs} to start the compare at. At least * 20 bytes, starting at this position are required. * @return <0 if this abbreviation names an object that is less than * <code>other</code>; 0 if this abbreviation exactly matches the * first {@link #length()} digits of <code>other.name()</code>; * >0 if this abbreviation names an object that is after * <code>other</code>. */ public final int prefixCompare(byte[] bs, int p) { int cmp; cmp = NB.compareUInt32(w1, mask(1, NB.decodeInt32(bs, p))); if (cmp != 0) return cmp; cmp = NB.compareUInt32(w2, mask(2, NB.decodeInt32(bs, p + 4))); if (cmp != 0) return cmp; cmp = NB.compareUInt32(w3, mask(3, NB.decodeInt32(bs, p + 8))); if (cmp != 0) return cmp; cmp = NB.compareUInt32(w4, mask(4, NB.decodeInt32(bs, p + 12))); if (cmp != 0) return cmp; return NB.compareUInt32(w5, mask(5, NB.decodeInt32(bs, p + 16))); }
private int mask(int word, int v) { return mask(nibbles, word, v); }
private int mask(final int word, final int v) { return mask(nibbles, word, v); }
/** * Return an abbreviation (prefix) of this object SHA-1. * <p> * This implementation does not guarantee uniqueness. Callers should * instead use {@link ObjectReader#abbreviate(AnyObjectId, int)} to obtain a * unique abbreviation within the scope of a particular object database. * * @param len * length of the abbreviated string. * @return SHA-1 abbreviation. */ public AbbreviatedObjectId abbreviate(final int len) { final int a = AbbreviatedObjectId.mask(len, 1, w1); final int b = AbbreviatedObjectId.mask(len, 2, w2); final int c = AbbreviatedObjectId.mask(len, 3, w3); final int d = AbbreviatedObjectId.mask(len, 4, w4); final int e = AbbreviatedObjectId.mask(len, 5, w5); return new AbbreviatedObjectId(len, a, b, c, d, e); }
/** * Return an abbreviation (prefix) of this object SHA-1. * <p> * This implementation does not guarantee uniqueness. Callers should instead * use * {@link org.eclipse.jgit.lib.ObjectReader#abbreviate(AnyObjectId, int)} to * obtain a unique abbreviation within the scope of a particular object * database. * * @param len * length of the abbreviated string. * @return SHA-1 abbreviation. */ public AbbreviatedObjectId abbreviate(int len) { final int a = AbbreviatedObjectId.mask(len, 1, w1); final int b = AbbreviatedObjectId.mask(len, 2, w2); final int c = AbbreviatedObjectId.mask(len, 3, w3); final int d = AbbreviatedObjectId.mask(len, 4, w4); final int e = AbbreviatedObjectId.mask(len, 5, w5); return new AbbreviatedObjectId(len, a, b, c, d, e); }
/** * Compares this abbreviation to a full object id. * * @param other * the other object id. * @return <0 if this abbreviation names an object that is less than * <code>other</code>; 0 if this abbreviation exactly matches the * first {@link #length()} digits of <code>other.name()</code>; * >0 if this abbreviation names an object that is after * <code>other</code>. */ public final int prefixCompare(final AnyObjectId other) { int cmp; cmp = NB.compareUInt32(w1, mask(1, other.w1)); if (cmp != 0) return cmp; cmp = NB.compareUInt32(w2, mask(2, other.w2)); if (cmp != 0) return cmp; cmp = NB.compareUInt32(w3, mask(3, other.w3)); if (cmp != 0) return cmp; cmp = NB.compareUInt32(w4, mask(4, other.w4)); if (cmp != 0) return cmp; return NB.compareUInt32(w5, mask(5, other.w5)); }
/** * Compare this abbreviation to a network-byte-order ObjectId. * * @param bs * array containing the other ObjectId in network byte order. * @param p * position within {@code bs} to start the compare at. At least 5 * ints, starting at this position are required. * @return <0 if this abbreviation names an object that is less than * <code>other</code>; 0 if this abbreviation exactly matches the * first {@link #length()} digits of <code>other.name()</code>; * >0 if this abbreviation names an object that is after * <code>other</code>. */ public final int prefixCompare(final int[] bs, final int p) { int cmp; cmp = NB.compareUInt32(w1, mask(1, bs[p])); if (cmp != 0) return cmp; cmp = NB.compareUInt32(w2, mask(2, bs[p + 1])); if (cmp != 0) return cmp; cmp = NB.compareUInt32(w3, mask(3, bs[p + 2])); if (cmp != 0) return cmp; cmp = NB.compareUInt32(w4, mask(4, bs[p + 3])); if (cmp != 0) return cmp; return NB.compareUInt32(w5, mask(5, bs[p + 4])); }
/** * Compares this abbreviation to a full object id. * * @param other * the other object id. * @return <0 if this abbreviation names an object that is less than * <code>other</code>; 0 if this abbreviation exactly matches the * first {@link #length()} digits of <code>other.name()</code>; * >0 if this abbreviation names an object that is after * <code>other</code>. */ public final int prefixCompare(AnyObjectId other) { int cmp; cmp = NB.compareUInt32(w1, mask(1, other.w1)); if (cmp != 0) return cmp; cmp = NB.compareUInt32(w2, mask(2, other.w2)); if (cmp != 0) return cmp; cmp = NB.compareUInt32(w3, mask(3, other.w3)); if (cmp != 0) return cmp; cmp = NB.compareUInt32(w4, mask(4, other.w4)); if (cmp != 0) return cmp; return NB.compareUInt32(w5, mask(5, other.w5)); }
/** * Compare this abbreviation to a network-byte-order ObjectId. * * @param bs * array containing the other ObjectId in network byte order. * @param p * position within {@code bs} to start the compare at. At least 5 * ints, starting at this position are required. * @return <0 if this abbreviation names an object that is less than * <code>other</code>; 0 if this abbreviation exactly matches the * first {@link #length()} digits of <code>other.name()</code>; * >0 if this abbreviation names an object that is after * <code>other</code>. */ public final int prefixCompare(int[] bs, int p) { int cmp; cmp = NB.compareUInt32(w1, mask(1, bs[p])); if (cmp != 0) return cmp; cmp = NB.compareUInt32(w2, mask(2, bs[p + 1])); if (cmp != 0) return cmp; cmp = NB.compareUInt32(w3, mask(3, bs[p + 2])); if (cmp != 0) return cmp; cmp = NB.compareUInt32(w4, mask(4, bs[p + 3])); if (cmp != 0) return cmp; return NB.compareUInt32(w5, mask(5, bs[p + 4])); }
/** * Compare this abbreviation to a network-byte-order ObjectId. * * @param bs * array containing the other ObjectId in network byte order. * @param p * position within {@code bs} to start the compare at. At least * 20 bytes, starting at this position are required. * @return <0 if this abbreviation names an object that is less than * <code>other</code>; 0 if this abbreviation exactly matches the * first {@link #length()} digits of <code>other.name()</code>; * >0 if this abbreviation names an object that is after * <code>other</code>. */ public final int prefixCompare(final byte[] bs, final int p) { int cmp; cmp = NB.compareUInt32(w1, mask(1, NB.decodeInt32(bs, p))); if (cmp != 0) return cmp; cmp = NB.compareUInt32(w2, mask(2, NB.decodeInt32(bs, p + 4))); if (cmp != 0) return cmp; cmp = NB.compareUInt32(w3, mask(3, NB.decodeInt32(bs, p + 8))); if (cmp != 0) return cmp; cmp = NB.compareUInt32(w4, mask(4, NB.decodeInt32(bs, p + 12))); if (cmp != 0) return cmp; return NB.compareUInt32(w5, mask(5, NB.decodeInt32(bs, p + 16))); }
/** * Compare this abbreviation to a network-byte-order ObjectId. * * @param bs * array containing the other ObjectId in network byte order. * @param p * position within {@code bs} to start the compare at. At least * 20 bytes, starting at this position are required. * @return <0 if this abbreviation names an object that is less than * <code>other</code>; 0 if this abbreviation exactly matches the * first {@link #length()} digits of <code>other.name()</code>; * >0 if this abbreviation names an object that is after * <code>other</code>. */ public final int prefixCompare(byte[] bs, int p) { int cmp; cmp = NB.compareUInt32(w1, mask(1, NB.decodeInt32(bs, p))); if (cmp != 0) return cmp; cmp = NB.compareUInt32(w2, mask(2, NB.decodeInt32(bs, p + 4))); if (cmp != 0) return cmp; cmp = NB.compareUInt32(w3, mask(3, NB.decodeInt32(bs, p + 8))); if (cmp != 0) return cmp; cmp = NB.compareUInt32(w4, mask(4, NB.decodeInt32(bs, p + 12))); if (cmp != 0) return cmp; return NB.compareUInt32(w5, mask(5, NB.decodeInt32(bs, p + 16))); }