Changeset e691245


Ignore:
Timestamp:
Dec 2, 2018 3:21:30 PM (2 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
ee722b7
Parents:
7c928f9
Message:

DataHelper?: Minor efficiency improvements in Properties methods

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • core/java/src/net/i2p/data/DataHelper.java

    r7c928f9 re691245  
    149149    public static Properties readProperties(InputStream rawStream, Properties props)
    150150        throws DataFormatException, IOException {
    151         long size = readLong(rawStream, 2);
    152         byte data[] = new byte[(int) size];
    153         int read = read(rawStream, data);
    154         if (read != size) throw new DataFormatException("Not enough data to read the properties, expected " + size + " but got " + read);
     151        int size = (int) readLong(rawStream, 2);
     152        if (size == 0)
     153            return props;
     154        byte data[] = new byte[size];
     155        // full read guaranteed
     156        read(rawStream, data);
    155157        ByteArrayInputStream in = new ByteArrayInputStream(data);
    156158        while (in.available() > 0) {
     
    214216    public static void writeProperties(OutputStream rawStream, Properties props, boolean utf8)
    215217            throws DataFormatException, IOException {
    216         writeProperties(rawStream, props, utf8, props != null && !(props instanceof OrderedProperties));
     218        writeProperties(rawStream, props, utf8, props != null && props.size() > 1 && !(props instanceof OrderedProperties));
    217219    }
    218220
     
    243245        if (props != null && !props.isEmpty()) {
    244246            Properties p;
    245             if (sort) {
     247            if (sort && props.size() > 1) {
    246248                p = new OrderedProperties();
    247249                p.putAll(props);
     
    867869        size &= 0xff;
    868870        byte raw[] = new byte[size];
    869         int read = read(in, raw);
    870         // was DataFormatException
    871         if (read != size) throw new EOFException("EOF reading string");
     871        // full read guaranteed
     872        read(in, raw);
    872873        // the following constructor throws an UnsupportedEncodingException which is an IOException,
    873874        // but that's only if UTF-8 is not supported. Other encoding errors are not thrown.
  • history.txt

    r7c928f9 re691245  
     12018-12-01 zzz
     2 * I2CP: Add preliminary support for LS2 (proposal #123)
     3 * Router: More support for LS2 types (proposal #123)
     4
     52018-11-30 zzz
     6 * Crypto: Move X25519 primitives from router to core (proposal #144)
     7 * Data: Update LS2 sign/verify to match spec changes (proposal #123)
     8
     92018-11-25 zzz
     10 * Utils: Catch ProviderException in SelfSignedGenerator (ticket #2344)
     11
    1122018-11-20 zzz
    213 * GeoIP: Add support for Maxmind GeoLite2 format (ticket #2268)
  • router/java/src/net/i2p/router/RouterVersion.java

    r7c928f9 re691245  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 6;
     21    public final static long BUILD = 7;
    2222
    2323    /** for example "-test" */
Note: See TracChangeset for help on using the changeset viewer.