Description length cannot be negative, therefore if we use write (unsigned) instead of writeByte (signed) we can potentially use one more byte.
This commit is contained in:
parent
875c5b4ddd
commit
e48cc1a704
1 changed files with 5 additions and 5 deletions
|
@ -29,7 +29,7 @@ public class NodeData extends MapCreatorBase
|
|||
ilon = (int)dis.readDiffed( 1 );
|
||||
ilat = (int)dis.readDiffed( 2 );
|
||||
int mode = dis.readByte();
|
||||
if ( ( mode & 1 ) != 0 ) { int dlen = dis.readByte(); description = new byte[dlen]; dis.readFully( description ); }
|
||||
if ( ( mode & 1 ) != 0 ) { int dlen = dis.read(); description = new byte[dlen]; dis.readFully( description ); }
|
||||
if ( ( mode & 2 ) != 0 ) selev = dis.readShort();
|
||||
}
|
||||
|
||||
|
@ -38,9 +38,9 @@ public class NodeData extends MapCreatorBase
|
|||
dos.writeDiffed( nid, 0 );
|
||||
dos.writeDiffed( ilon, 1 );
|
||||
dos.writeDiffed( ilat, 2 );
|
||||
int mode = ( description == null ? 0 : 1 ) | ( selev == Short.MIN_VALUE ? 0 : 2 );
|
||||
dos.writeByte( (byte)mode );
|
||||
if ( ( mode & 1 ) != 0 ) { dos.writeByte( description.length ); dos.write( description ); }
|
||||
if ( ( mode & 2 ) != 0 ) dos.writeShort( selev );
|
||||
int mode = (description == null ? 0 : 1) | (selev == Short.MIN_VALUE ? 0 : 2);
|
||||
dos.writeByte((byte) mode);
|
||||
if ((mode & 1) != 0) { dos.write(description.length); dos.write(description); }
|
||||
if ((mode & 2) != 0) dos.writeShort(selev);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue