Skip to content

Commit e4d8b2d

Browse files
author
bytekeeper
committed
Reverted: Use builtin "endian" conversion.
1 parent fb31ad8 commit e4d8b2d

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/main/java/bwapi/Client.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,27 @@ class LittleEndianPipe {
115115
pipe = new RandomAccessFile(name, mode);
116116
}
117117

118+
final int readByte() throws IOException {
119+
return pipe.readByte();
120+
}
121+
122+
final void writeByte(final int b) throws IOException {
123+
pipe.writeByte(b);
124+
}
125+
118126
final int readInt() throws IOException {
119-
return Integer.reverseBytes(pipe.readInt());
127+
final int b1 = readByte();
128+
final int b2 = readByte();
129+
final int b3 = readByte();
130+
final int b4 = readByte();
131+
return (b4 << 24) | (b3 << 16) | (b2 << 8) | b1;
120132
}
121133

122134
final void writeInt(final int i) throws IOException {
123-
pipe.writeInt(Integer.reverseBytes(i));
135+
writeByte(i >> 24);
136+
writeByte((i >> 16) & 0xff);
137+
writeByte((i >> 8) & 0xff);
138+
writeByte(i & 0xff);
124139
}
125140
}
126141

0 commit comments

Comments
 (0)