Skip to content

Commit

Permalink
Improve names, tests, checks for writing and reading bytes of a long.
Browse files Browse the repository at this point in the history
  • Loading branch information
Wojtek Gdela committed Oct 17, 2023
1 parent 62bcd2d commit 029190b
Show file tree
Hide file tree
Showing 6 changed files with 1,138 additions and 1,092 deletions.
3 changes: 2 additions & 1 deletion src/com/esotericsoftware/kryo/io/ByteBufferInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,8 @@ public void readBytes (byte[] bytes, int offset, int count) throws KryoException
}
}

public long readBytesAsLong (int count) {
public long readLong (int count) {
if (count < 0 || count > 8) throw new IllegalArgumentException("count must be >= 0 and <= 8: " + count);
require(count);
position += count;
long bytes = byteBuffer.get();
Expand Down
3 changes: 2 additions & 1 deletion src/com/esotericsoftware/kryo/io/ByteBufferOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@ public void writeBytes (byte[] bytes, int offset, int count) throws KryoExceptio
}
}

public void writeBytesFromLong (long bytes, int count) {
public void writeLong (long bytes, int count) {
if (count < 0 || count > 8) throw new IllegalArgumentException("count must be >= 0 and <= 8: " + count);
require(count);
position += count;
for (int i = count - 1; i >= 0; i--) {
Expand Down
3 changes: 2 additions & 1 deletion src/com/esotericsoftware/kryo/io/Input.java
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,8 @@ public void readBytes (byte[] bytes, int offset, int count) throws KryoException
}

/** Reads count bytes and returns them as long, the last byte read will be the lowest byte in the long. */
public long readBytesAsLong (int count) {
public long readLong (int count) {
if (count < 0 || count > 8) throw new IllegalArgumentException("count must be >= 0 and <= 8: " + count);
require(count);
int p = position;
position = p + count;
Expand Down
3 changes: 2 additions & 1 deletion src/com/esotericsoftware/kryo/io/Output.java
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@ public void writeBytes (byte[] bytes, int offset, int count) throws KryoExceptio

/** Writes count bytes from long, the last byte written is the lowest byte from the long.
* Note the number of bytes is not written. */
public void writeBytesFromLong (long bytes, int count) {
public void writeLong (long bytes, int count) {
if (count < 0 || count > 8) throw new IllegalArgumentException("count must be >= 0 and <= 8: " + count);
require(count);
int p = position;
position = p + count;
Expand Down
Loading

0 comments on commit 029190b

Please sign in to comment.