Mercurial > jhg
comparison src/org/tmatesoft/hg/core/Nodeid.java @ 197:3a7696fb457c
Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Tue, 19 Apr 2011 03:49:29 +0200 |
parents | 71ddbf8603e8 |
children | 4b661efb9374 |
comparison
equal
deleted
inserted
replaced
196:e2115da4cf6a | 197:3a7696fb457c |
---|---|
44 * @param shallClone - true if array is subject to future modification and shall be copied, not referenced | 44 * @param shallClone - true if array is subject to future modification and shall be copied, not referenced |
45 * @throws IllegalArgumentException if supplied binary representation doesn't correspond to 20 bytes of sha1 digest | 45 * @throws IllegalArgumentException if supplied binary representation doesn't correspond to 20 bytes of sha1 digest |
46 */ | 46 */ |
47 public Nodeid(byte[] binaryRepresentation, boolean shallClone) { | 47 public Nodeid(byte[] binaryRepresentation, boolean shallClone) { |
48 // 5 int fields => 32 bytes | 48 // 5 int fields => 32 bytes |
49 // byte[20] => 48 bytes | 49 // byte[20] => 48 bytes (16 bytes is Nodeid with one field, 32 bytes for byte[20] |
50 if (binaryRepresentation == null || binaryRepresentation.length != 20) { | 50 if (binaryRepresentation == null || binaryRepresentation.length != 20) { |
51 throw new IllegalArgumentException(); | 51 throw new IllegalArgumentException(); |
52 } | 52 } |
53 this.binaryData = shallClone ? binaryRepresentation.clone() : binaryRepresentation; | 53 /* |
54 * byte[].clone() is not reflected when ran with -agentlib:hprof=heap=sites | |
55 * thus not to get puzzled why there are N Nodeids and much less byte[] instances, | |
56 * may use following code to see N byte[] as well. | |
57 * | |
58 if (shallClone) { | |
59 binaryData = new byte[20]; | |
60 System.arraycopy(binaryRepresentation, 0, binaryData, 0, 20); | |
61 } else { | |
62 binaryData = binaryRepresentation; | |
63 } | |
64 */ | |
65 binaryData = shallClone ? binaryRepresentation.clone() : binaryRepresentation; | |
54 } | 66 } |
55 | 67 |
56 @Override | 68 @Override |
57 public int hashCode() { | 69 public int hashCode() { |
58 // digest (part thereof) seems to be nice candidate for the hashCode | 70 // digest (part thereof) seems to be nice candidate for the hashCode |