3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-09-17 01:23:43 +02:00

Temp arrays are evil, (memory optimisation)

Dieser Commit ist enthalten in:
Myles 2016-03-07 19:19:14 +00:00
Ursprung a92a7d6e02
Commit 012eec47b5

Datei anzeigen

@ -60,11 +60,11 @@ public class NetUtil {
chunks[ind] = new Chunk(sky || hasSkyLight);
buf.position(pos / 2);
short[] tempData = new short[4096];
buf.get(tempData, 0, tempData.length);
int buffPos = buf.position();
// convert short array to new one
int index = 0;
for(short ss:tempData){
for (int index = 0; index < 4096; index++) {
short ss = buf.get(buffPos + index);
// s is 16 bits, 12 bits id and 4 bits data
int data = ss & 0xF;
int id = (ss >> 4) << 4 | data;
@ -72,9 +72,8 @@ public class NetUtil {
int newCombined = id; // test
chunks[ind].getBlocks().set(index, newCombined);
index++;
}
pos += tempData.length * 2;
pos += 4096 * 2;
}