Changeset a5a5f7d for router


Ignore:
Timestamp:
Aug 4, 2018 2:50:33 PM (2 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
9b3eb8d
Parents:
30f25de
Message:

I2NP: Don't call toLong() for 1 byte

Location:
router/java/src/net/i2p/data/i2np
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/data/i2np/DatabaseSearchReplyMessage.java

    r30f25de ra5a5f7d  
    104104        System.arraycopy(_key.getData(), 0, out, curIndex, Hash.HASH_LENGTH);
    105105        curIndex += Hash.HASH_LENGTH;
    106         DataHelper.toLong(out, curIndex, 1, _peerHashes.size());
    107         curIndex++;
     106        out[curIndex++] = (byte) _peerHashes.size();
    108107        for (int i = 0; i < getNumReplies(); i++) {
    109108            System.arraycopy(getReply(i).getData(), 0, out, curIndex, Hash.HASH_LENGTH);
  • router/java/src/net/i2p/data/i2np/DeliveryInstructions.java

    r30f25de ra5a5f7d  
    412412        //               + " =?= " + flagMode(flags));
    413413        int origOffset = offset;
    414         DataHelper.toLong(target, offset, 1, flags);
    415         offset++;
     414        target[offset++] = (byte) flags;
    416415        offset += getAdditionalInfo(target, offset);
    417416        return offset - origOffset;
  • router/java/src/net/i2p/data/i2np/FastI2NPMessageImpl.java

    r30f25de ra5a5f7d  
    151151            int payloadLen = writtenLen - HEADER_LENGTH;
    152152            int off = 0;
    153             DataHelper.toLong(buffer, off, 1, getType());
    154             off += 1;
     153            buffer[off++] = (byte) getType();
    155154            DataHelper.toLong(buffer, off, 4, _uniqueId);
    156155            off += 4;
  • router/java/src/net/i2p/data/i2np/I2NPMessageImpl.java

    r30f25de ra5a5f7d  
    258258            _context.sha().calculateHash(buffer, off + HEADER_LENGTH, payloadLen, h, 0);
    259259
    260             DataHelper.toLong(buffer, off, 1, getType());
    261             off++;
     260            buffer[off++] = (byte) getType();
    262261
    263262            // Lazy initialization of value
     
    301300        try {
    302301            int off = 0;
    303             DataHelper.toLong(buffer, off, 1, getType());
    304             off += 1;
     302            buffer[off++] = (byte) getType();
    305303            // January 19 2038? No, unsigned, good until Feb. 7 2106
    306304            // in seconds, round up so we don't lose time every hop
     
    326324    public int toRawByteArrayNTCP2(byte buffer[], int off) {
    327325        try {
    328             DataHelper.toLong(buffer, off, 1, getType());
    329             off += 1;
     326            buffer[off++] = (byte) getType();
    330327            // Lazy initialization of value
    331328            if (_uniqueId < 0) {
  • router/java/src/net/i2p/data/i2np/VariableTunnelBuildMessage.java

    r30f25de ra5a5f7d  
    22
    33import net.i2p.I2PAppContext;
    4 import net.i2p.data.DataHelper;
    54
    65/**
     
    4746        if (RECORD_COUNT <= 0 || RECORD_COUNT > MAX_RECORD_COUNT)
    4847            throw new I2NPMessageException("Bad record count " + RECORD_COUNT);
    49         DataHelper.toLong(out, curIndex++, 1, RECORD_COUNT);
     48        out[curIndex++] = (byte) RECORD_COUNT;
    5049        // can't call super, written length check will fail
    5150        //return super.writeMessageBody(out, curIndex + 1);
  • router/java/src/net/i2p/data/i2np/VariableTunnelBuildReplyMessage.java

    r30f25de ra5a5f7d  
    4949        if (RECORD_COUNT <= 0 || RECORD_COUNT > MAX_RECORD_COUNT)
    5050            throw new I2NPMessageException("Bad record count " + RECORD_COUNT);
    51         DataHelper.toLong(out, curIndex++, 1, RECORD_COUNT);
     51        out[curIndex++] = (byte) RECORD_COUNT;
    5252        // can't call super, written length check will fail
    5353        //return super.writeMessageBody(out, curIndex + 1);
Note: See TracChangeset for help on using the changeset viewer.