Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/com/esotericsoftware/kryo/unsafe/UnsafeByteBufferOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,47 +185,47 @@ public void writeBoolean (boolean value) throws KryoException {
}

public void writeInts (int[] array, int offset, int count) throws KryoException {
writeBytes(array, intArrayBaseOffset, array.length << 2);
writeBytes(array, intArrayBaseOffset + ((long)offset << 2), (long)count << 2);
}

public void writeLongs (long[] array, int offset, int count) throws KryoException {
writeBytes(array, longArrayBaseOffset, array.length << 3);
writeBytes(array, longArrayBaseOffset + ((long)offset << 3), (long)count << 3);
}

public void writeFloats (float[] array, int offset, int count) throws KryoException {
writeBytes(array, floatArrayBaseOffset, array.length << 2);
writeBytes(array, floatArrayBaseOffset + ((long)offset << 2), (long)count << 2);
}

public void writeDoubles (double[] array, int offset, int count) throws KryoException {
writeBytes(array, doubleArrayBaseOffset, array.length << 3);
writeBytes(array, doubleArrayBaseOffset + ((long)offset << 3), (long)count << 3);
}

public void writeShorts (short[] array, int offset, int count) throws KryoException {
writeBytes(array, shortArrayBaseOffset, array.length << 1);
writeBytes(array, shortArrayBaseOffset + ((long)offset << 1), (long)count << 1);
}

public void writeChars (char[] array, int offset, int count) throws KryoException {
writeBytes(array, charArrayBaseOffset, array.length << 1);
writeBytes(array, charArrayBaseOffset + ((long)offset << 1), (long)count << 1);
}

public void writeBooleans (boolean[] array, int offset, int count) throws KryoException {
writeBytes(array, booleanArrayBaseOffset, array.length);
writeBytes(array, booleanArrayBaseOffset + offset, count);
}

public void writeBytes (byte[] array, int offset, int count) throws KryoException {
writeBytes(array, byteArrayBaseOffset + offset, count);
writeBytes(array, byteArrayBaseOffset + offset, (long)count);
}

/** Write count bytes to the byte buffer, reading from the given offset inside the in-memory representation of the object. */
public void writeBytes (Object from, long offset, int count) throws KryoException {
int copyCount = Math.min(capacity - position, count);
public void writeBytes (Object from, long offset, long count) throws KryoException {
int copyCount = (int)Math.min(capacity - position, count);
while (true) {
unsafe.copyMemory(from, offset, null, bufferAddress + position, copyCount);
position += copyCount;
count -= copyCount;
if (count == 0) break;
offset += copyCount;
copyCount = Math.min(capacity, count);
copyCount = (int)Math.min(capacity, count);
require(copyCount);
}
setBufferPosition(byteBuffer, position);
Expand Down
22 changes: 11 additions & 11 deletions src/com/esotericsoftware/kryo/unsafe/UnsafeOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,47 +135,47 @@ public void writeBoolean (boolean value) throws KryoException {
}

public void writeInts (int[] array, int offset, int count) throws KryoException {
writeBytes(array, intArrayBaseOffset, array.length << 2);
writeBytes(array, intArrayBaseOffset + ((long)offset << 2), (long)count << 2);
}

public void writeLongs (long[] array, int offset, int count) throws KryoException {
writeBytes(array, longArrayBaseOffset, array.length << 3);
writeBytes(array, longArrayBaseOffset + ((long)offset << 3), (long)count << 3);
}

public void writeFloats (float[] array, int offset, int count) throws KryoException {
writeBytes(array, floatArrayBaseOffset, array.length << 2);
writeBytes(array, floatArrayBaseOffset + ((long)offset << 2), (long)count << 2);
}

public void writeDoubles (double[] array, int offset, int count) throws KryoException {
writeBytes(array, doubleArrayBaseOffset, array.length << 3);
writeBytes(array, doubleArrayBaseOffset + ((long)offset << 3), (long)count << 3);
}

public void writeShorts (short[] array, int offset, int count) throws KryoException {
writeBytes(array, shortArrayBaseOffset, array.length << 1);
writeBytes(array, shortArrayBaseOffset + ((long)offset << 1), (long)count << 1);
}

public void writeChars (char[] array, int offset, int count) throws KryoException {
writeBytes(array, charArrayBaseOffset, array.length << 1);
writeBytes(array, charArrayBaseOffset + ((long)offset << 1), (long)count << 1);
}

public void writeBooleans (boolean[] array, int offset, int count) throws KryoException {
writeBytes(array, booleanArrayBaseOffset, array.length);
writeBytes(array, booleanArrayBaseOffset + offset, count);
}

public void writeBytes (byte[] array, int offset, int count) throws KryoException {
writeBytes(array, byteArrayBaseOffset + offset, count);
writeBytes(array, byteArrayBaseOffset + offset, (long)count);
}

/** Write count bytes to the byte buffer, reading from the given offset inside the in-memory representation of the object. */
public void writeBytes (Object from, long offset, int count) throws KryoException {
int copyCount = Math.min(capacity - position, count);
public void writeBytes (Object from, long offset, long count) throws KryoException {
int copyCount = (int)Math.min(capacity - position, count);
while (true) {
unsafe.copyMemory(from, offset, buffer, byteArrayBaseOffset + position, copyCount);
position += copyCount;
count -= copyCount;
if (count == 0) break;
offset += copyCount;
copyCount = Math.min(capacity, count);
copyCount = (int)Math.min(capacity, count);
require(copyCount);
}
}
Expand Down
Loading