New posts
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.invoke.VarHandle;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
/** AFTER: the same access through a byte-array-view VarHandle (JDK 9). Bounds-checked; native byte order to match Unsafe. */
|
||||
public final class ViewBytes {
|
||||
private ViewBytes() {}
|
||||
private static final VarHandle VIEW = MethodHandles.byteArrayViewVarHandle(long[].class, ByteOrder.nativeOrder());
|
||||
|
||||
public static long get(byte[] a, int off) { return (long) VIEW.get(a, off); }
|
||||
public static void put(byte[] a, int off, long v) { VIEW.set(a, off, v); }
|
||||
}
|
||||
Reference in New Issue
Block a user