# HG changeset patch # User Artem Tikhomirov # Date 1294716874 -3600 # Node ID b2251b7a982366fc299f88ac363260546c037a51 # Parent b0a15cefdfd6058ec267fd546d3db2b51ad39654 Explicit cons arg for clone is more error-prone diff -r b0a15cefdfd6 -r b2251b7a9823 src/com/tmate/hgkit/ll/HgManifest.java --- a/src/com/tmate/hgkit/ll/HgManifest.java Sun Jan 09 16:02:26 2011 +0100 +++ b/src/com/tmate/hgkit/ll/HgManifest.java Tue Jan 11 04:34:34 2011 +0100 @@ -22,7 +22,7 @@ if (!gtg) { return; } - gtg = gtg && inspector.begin(revisionNumber, new Nodeid(nodeid.clone())); + gtg = gtg && inspector.begin(revisionNumber, new Nodeid(nodeid, true)); int i; String fname = null; String flags = null; diff -r b0a15cefdfd6 -r b2251b7a9823 src/com/tmate/hgkit/ll/Nodeid.java --- a/src/com/tmate/hgkit/ll/Nodeid.java Sun Jan 09 16:02:26 2011 +0100 +++ b/src/com/tmate/hgkit/ll/Nodeid.java Tue Jan 11 04:34:34 2011 +0100 @@ -21,15 +21,16 @@ private final byte[] binaryData; /** - * @param binaryRepresentation - byte[20], kept by reference. Use {@link #clone()} if original array may get changed. + * @param binaryRepresentation - byte[20], kept by reference + * @param shallClone - true if array is subject to future modification and shall be copied, not referenced */ - public Nodeid(byte[] binaryRepresentation) { + public Nodeid(byte[] binaryRepresentation, boolean shallClone) { // 5 int fields => 32 bytes // byte[20] => 48 bytes if (binaryRepresentation == null || binaryRepresentation.length != 20) { throw new IllegalArgumentException(); } - this.binaryData = binaryRepresentation; + this.binaryData = shallClone ? binaryRepresentation.clone() : binaryRepresentation; } @Override @@ -66,6 +67,6 @@ int lowNibble = Character.digit(asciiRepresentation[j++], 16); data[i] = (byte) (((hiNibble << 4) | lowNibble) & 0xFF); } - return new Nodeid(data); + return new Nodeid(data, false); } }