Changeset a2c867c
- Timestamp:
- Sep 24, 2011 9:45:52 PM (9 years ago)
- Branches:
- master
- Children:
- 4822e47
- Parents:
- fd1c8c4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
core/java/src/net/i2p/data/DataHelper.java
rfd1c8c4 ra2c867c 56 56 */ 57 57 public class DataHelper { 58 private static final byte EQUAL_BYTES[]; 59 private static final byte SEMICOLON_BYTES[]; 60 static { 61 try { 62 EQUAL_BYTES = "=".getBytes("UTF-8"); 63 SEMICOLON_BYTES = ";".getBytes("UTF-8"); 64 } catch (UnsupportedEncodingException uee) { 65 throw new RuntimeException("no utf8!?"); 66 } 67 } 58 private static final byte[] EQUAL_BYTES = getUTF8("="); 59 private static final byte[] SEMICOLON_BYTES = getUTF8(";"); 68 60 69 61 /** Read a mapping from the stream, as defined by the I2P data structure spec, -
router/java/src/net/i2p/router/networkdb/kademlia/XORComparator.java
rfd1c8c4 ra2c867c 11 11 */ 12 12 class XORComparator implements Comparator<Hash> { 13 private final Hash_base;13 private final byte[] _base; 14 14 15 15 /** … … 17 17 */ 18 18 public XORComparator(Hash target) { 19 _base = target ;19 _base = target.getData(); 20 20 } 21 21 22 22 public int compare(Hash lhs, Hash rhs) { 23 if (lhs == null) throw new NullPointerException("LHS is null"); 24 if (rhs == null) throw new NullPointerException("RHS is null"); 25 byte lhsDelta[] = DataHelper.xor(lhs.getData(), _base.getData()); 26 byte rhsDelta[] = DataHelper.xor(rhs.getData(), _base.getData()); 23 byte lhsDelta[] = DataHelper.xor(lhs.getData(), _base); 24 byte rhsDelta[] = DataHelper.xor(rhs.getData(), _base); 27 25 return DataHelper.compareTo(lhsDelta, rhsDelta); 28 26 }
Note: See TracChangeset
for help on using the changeset viewer.