Changeset 1451dc6


Ignore:
Timestamp:
Nov 8, 2015 8:43:42 PM (5 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
c1afbd3
Parents:
1aed266
Message:

More: Don't use DataHelper?.readLong() for 1-byte reads, for efficiency

Files:
12 edited

Legend:

Unmodified
Added
Removed
  • apps/streaming/java/src/net/i2p/client/streaming/impl/Packet.java

    r1aed266 r1451dc6  
    586586        setAckThrough(DataHelper.fromLong(buffer, cur, 4));
    587587        cur += 4;
    588         int numNacks = (int)DataHelper.fromLong(buffer, cur, 1);
     588        int numNacks = buffer[cur] & 0xff;
    589589        cur++;
    590590        if (length < 22 + numNacks*4)
     
    600600            setNacks(null);
    601601        }
    602         setResendDelay((int)DataHelper.fromLong(buffer, cur, 1));
     602        setResendDelay(buffer[cur] & 0xff);
    603603        cur++;
    604604        setFlags((int)DataHelper.fromLong(buffer, cur, 2));
  • core/java/src/net/i2p/data/Certificate.java

    r1aed266 r1451dc6  
    216216
    217217        int cur = offset;
    218         _type = (int)DataHelper.fromLong(source, cur, 1);
     218        _type = source[cur] & 0xff;
    219219        cur++;
    220220        int length = (int)DataHelper.fromLong(source, cur, 2);
  • router/java/src/net/i2p/data/i2np/DatabaseSearchReplyMessage.java

    r1aed266 r1451dc6  
    6969        //_key = new Hash(keyData);
    7070       
    71         int num = (int)DataHelper.fromLong(data, curIndex, 1);
     71        int num = data[curIndex] & 0xff;
    7272        curIndex++;
    7373       
  • router/java/src/net/i2p/data/i2np/DeliveryInstructions.java

    r1aed266 r1451dc6  
    210210    public int readBytes(byte data[], int offset) throws DataFormatException {
    211211        int cur = offset;
    212         long flags = DataHelper.fromLong(data, cur, 1);
     212        int flags = data[cur] & 0xff;
    213213        cur++;
    214214        //if (_log.shouldLog(Log.DEBUG))
  • router/java/src/net/i2p/data/i2np/FastI2NPMessageImpl.java

    r1aed266 r1451dc6  
    8686        int cur = offset;
    8787        if (type < 0) {
    88             type = (int)DataHelper.fromLong(data, cur, 1);
     88            type = data[cur] & 0xff;
    8989            cur++;
    9090        }
  • router/java/src/net/i2p/data/i2np/I2NPMessageHandler.java

    r1aed266 r1451dc6  
    110110        int cur = offset;
    111111        // we will assume that maxLen is >= 1 here. It's checked to be >= 16 in readBytes()
    112         int type = (int)DataHelper.fromLong(data, cur, 1);
     112        int type = data[cur] & 0xff;
    113113        cur++;
    114114        _lastReadBegin = System.currentTimeMillis();
  • router/java/src/net/i2p/data/i2np/I2NPMessageImpl.java

    r1aed266 r1451dc6  
    198198        int cur = offset;
    199199        if (type < 0) {
    200             type = (int)DataHelper.fromLong(data, cur, 1);
     200            type = data[cur] & 0xff;
    201201            cur++;
    202202        }
     
    414414    public static I2NPMessage fromRawByteArray(I2PAppContext ctx, byte buffer[], int offset,
    415415                                               int len, I2NPMessageHandler handler) throws I2NPMessageException {
    416         int type = (int)DataHelper.fromLong(buffer, offset, 1);
     416        int type = buffer[offset] & 0xff;
    417417        offset++;
    418418        I2NPMessage msg = createMessage(ctx, type);
  • router/java/src/net/i2p/data/i2np/VariableTunnelBuildMessage.java

    r1aed266 r1451dc6  
    3030    public void readMessage(byte[] data, int offset, int dataSize, int type) throws I2NPMessageException {
    3131        // message type will be checked in super()
    32         int r = (int)DataHelper.fromLong(data, offset, 1);
     32        int r = data[offset] & 0xff;
    3333        if (r <= 0 || r > MAX_RECORD_COUNT)
    3434            throw new I2NPMessageException("Bad record count " + r);
  • router/java/src/net/i2p/data/i2np/VariableTunnelBuildReplyMessage.java

    r1aed266 r1451dc6  
    3232    public void readMessage(byte[] data, int offset, int dataSize, int type) throws I2NPMessageException {
    3333        // message type will be checked in super()
    34         int r = (int)DataHelper.fromLong(data, offset, 1);
     34        int r = data[offset] & 0xff;
    3535        if (r <= 0 || r > MAX_RECORD_COUNT)
    3636            throw new I2NPMessageException("Bad record count " + r);
  • router/java/src/net/i2p/router/message/GarlicMessageParser.java

    r1aed266 r1451dc6  
    7676        int offset = 0;
    7777       
    78         int numCloves = (int)DataHelper.fromLong(data, offset, 1);
     78        int numCloves = data[offset] & 0xff;
    7979        offset++;
    8080        if (_log.shouldLog(Log.DEBUG))
  • router/java/src/net/i2p/router/tunnel/BuildReplyHandler.java

    r1aed266 r1451dc6  
    121121        } else {
    122122            SimpleByteCache.release(h);
    123             int rv = (int)DataHelper.fromLong(data, TunnelBuildReplyMessage.RECORD_SIZE - 1, 1);
     123            int rv = data[TunnelBuildReplyMessage.RECORD_SIZE - 1] & 0xff;
    124124            if (log.shouldLog(Log.DEBUG))
    125125                log.debug(reply.getUniqueId() + ": Verified: " + rv + " for record " + recordNum + "/" + hop);
  • router/java/src/net/i2p/router/tunnel/FragmentHandler.java

    r1aed266 r1451dc6  
    341341        }
    342342        if (extended) {
    343             int extendedSize = (int)DataHelper.fromLong(preprocessed, offset, 1);
     343            int extendedSize = preprocessed[offset] & 0xff;
    344344            offset++;
    345345            offset += extendedSize; // we don't interpret these yet, but skip them for now
Note: See TracChangeset for help on using the changeset viewer.