Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-16 21:10:30 +01:00
Do some minor natives housekeeping.
Dieser Commit ist enthalten in:
Ursprung
55f9509c6e
Commit
a7654af1a3
@ -26,20 +26,6 @@ class CompressorUtils {
|
||||
*/
|
||||
static final int ZLIB_BUFFER_SIZE = 8192;
|
||||
|
||||
/**
|
||||
* Ensures that the buffer does not go over {@code max}.
|
||||
*
|
||||
* @param buf the buffer for check
|
||||
* @param max the maximum size for the buffer
|
||||
* @throws DataFormatException if the buffer becomes too bug
|
||||
*/
|
||||
static void ensureMaxSize(ByteBuf buf, int max) throws DataFormatException {
|
||||
int len = buf.readableBytes();
|
||||
if (len > max) {
|
||||
throw new DataFormatException("Got too much data (" + len + " > " + max + ")");
|
||||
}
|
||||
}
|
||||
|
||||
private CompressorUtils() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
@ -52,18 +52,13 @@ public class MoreByteBufUtils {
|
||||
|
||||
private static boolean isCompatible(Native nativeStuff, ByteBuf buf) {
|
||||
BufferPreference preferred = nativeStuff.preferredBufferType();
|
||||
switch (preferred) {
|
||||
case DIRECT_PREFERRED:
|
||||
case HEAP_PREFERRED:
|
||||
return switch (preferred) {
|
||||
case DIRECT_PREFERRED, HEAP_PREFERRED ->
|
||||
// The native prefers this type, but doesn't strictly require we provide it.
|
||||
return true;
|
||||
case DIRECT_REQUIRED:
|
||||
return buf.hasMemoryAddress();
|
||||
case HEAP_REQUIRED:
|
||||
return buf.hasArray();
|
||||
default:
|
||||
throw new AssertionError("Preferred buffer type unknown");
|
||||
}
|
||||
true;
|
||||
case DIRECT_REQUIRED -> buf.hasMemoryAddress();
|
||||
case HEAP_REQUIRED -> buf.hasArray();
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@ -77,15 +72,9 @@ public class MoreByteBufUtils {
|
||||
*/
|
||||
public static ByteBuf preferredBuffer(ByteBufAllocator alloc, Native nativeStuff,
|
||||
int initialCapacity) {
|
||||
switch (nativeStuff.preferredBufferType()) {
|
||||
case HEAP_REQUIRED:
|
||||
case HEAP_PREFERRED:
|
||||
return alloc.heapBuffer(initialCapacity);
|
||||
case DIRECT_PREFERRED:
|
||||
case DIRECT_REQUIRED:
|
||||
return alloc.directBuffer(initialCapacity);
|
||||
default:
|
||||
throw new AssertionError("Preferred buffer type unknown");
|
||||
}
|
||||
return switch (nativeStuff.preferredBufferType()) {
|
||||
case HEAP_REQUIRED, HEAP_PREFERRED -> alloc.heapBuffer(initialCapacity);
|
||||
case DIRECT_PREFERRED, DIRECT_REQUIRED -> alloc.directBuffer(initialCapacity);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -39,8 +39,6 @@ public class NativeConstraints {
|
||||
}
|
||||
|
||||
String osArch = System.getProperty("os.arch", "");
|
||||
// HotSpot on Intel macOS prefers x86_64, but OpenJ9 on macOS and HotSpot/OpenJ9 elsewhere
|
||||
// give amd64.
|
||||
IS_AMD64 = osArch.equals("amd64") || osArch.equals("x86_64");
|
||||
IS_AARCH64 = osArch.equals("aarch64") || osArch.equals("arm64");
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren