本文整理了Java中sun.misc.Unsafe.getChar()
方法的一些代码示例,展示了Unsafe.getChar()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Unsafe.getChar()
方法的具体详情如下:
包路径:sun.misc.Unsafe
类名称:Unsafe
方法名:getChar
暂无
代码示例来源:origin: redisson/redisson
@Override
public char getChar(long byteIndex) {
return unsafe.getChar(baseAdress + byteIndex);
}
代码示例来源:origin: neo4j/neo4j
public static char getChar( Object obj, long offset )
{
return unsafe.getChar( obj, offset );
}
代码示例来源:origin: apache/ignite
/**
* Gets char value from object field.
*
* @param obj Object.
* @param fieldOff Field offset.
* @return Char value from object field.
*/
public static char getCharField(Object obj, long fieldOff) {
return UNSAFE.getChar(obj, fieldOff);
}
代码示例来源:origin: bytedeco/javacpp
@Override char getChar(byte[] array, long offset) { return UNSAFE.getChar(array, arrayOffset + offset); }
@Override void putChar(byte[] array, long offset, char c) { UNSAFE.putChar(array, arrayOffset + offset, c); }
代码示例来源:origin: netty/netty
static boolean isZero(byte[] bytes, int startPos, int length) {
if (length <= 0) {
return true;
}
final long baseOffset = BYTE_ARRAY_BASE_OFFSET + startPos;
int remainingBytes = length & 7;
final long end = baseOffset + remainingBytes;
for (long i = baseOffset - 8 + length; i >= end; i -= 8) {
if (UNSAFE.getLong(bytes, i) != 0) {
return false;
}
}
if (remainingBytes >= 4) {
remainingBytes -= 4;
if (UNSAFE.getInt(bytes, baseOffset + remainingBytes) != 0) {
return false;
}
}
if (remainingBytes >= 2) {
return UNSAFE.getChar(bytes, baseOffset) == 0 &&
(remainingBytes == 2 || bytes[startPos + 2] == 0);
}
return bytes[startPos] == 0;
}
代码示例来源:origin: netty/netty
static boolean equals(byte[] bytes1, int startPos1, byte[] bytes2, int startPos2, int length) {
if (length <= 0) {
return true;
}
final long baseOffset1 = BYTE_ARRAY_BASE_OFFSET + startPos1;
final long baseOffset2 = BYTE_ARRAY_BASE_OFFSET + startPos2;
int remainingBytes = length & 7;
final long end = baseOffset1 + remainingBytes;
for (long i = baseOffset1 - 8 + length, j = baseOffset2 - 8 + length; i >= end; i -= 8, j -= 8) {
if (UNSAFE.getLong(bytes1, i) != UNSAFE.getLong(bytes2, j)) {
return false;
}
}
if (remainingBytes >= 4) {
remainingBytes -= 4;
if (UNSAFE.getInt(bytes1, baseOffset1 + remainingBytes) !=
UNSAFE.getInt(bytes2, baseOffset2 + remainingBytes)) {
return false;
}
}
if (remainingBytes >= 2) {
return UNSAFE.getChar(bytes1, baseOffset1) == UNSAFE.getChar(bytes2, baseOffset2) &&
(remainingBytes == 2 || bytes1[startPos1 + 2] == bytes2[startPos2 + 2]);
}
return bytes1[startPos1] == bytes2[startPos2];
}
代码示例来源:origin: redisson/redisson
public final int getCharValue(Object obj) throws IllegalAccessException {
if (!isAndroid && memOffset >= 0) {
return FSTUtil.unFlaggedUnsafe.getChar(obj, memOffset);
}
return field.getChar(obj);
}
代码示例来源:origin: redisson/redisson
@Override
public char getChar(long byteIndex) {
checkIndex(byteIndex,2);
return unsafe.getChar(base, off + byteIndex);
}
代码示例来源:origin: redisson/redisson
static boolean isZero(byte[] bytes, int startPos, int length) {
if (length <= 0) {
return true;
}
final long baseOffset = BYTE_ARRAY_BASE_OFFSET + startPos;
int remainingBytes = length & 7;
final long end = baseOffset + remainingBytes;
for (long i = baseOffset - 8 + length; i >= end; i -= 8) {
if (UNSAFE.getLong(bytes, i) != 0) {
return false;
}
}
if (remainingBytes >= 4) {
remainingBytes -= 4;
if (UNSAFE.getInt(bytes, baseOffset + remainingBytes) != 0) {
return false;
}
}
if (remainingBytes >= 2) {
return UNSAFE.getChar(bytes, baseOffset) == 0 &&
(remainingBytes == 2 || bytes[startPos + 2] == 0);
}
return bytes[startPos] == 0;
}
代码示例来源:origin: neo4j/neo4j
public static char getChar( long address )
{
checkAccess( address, Character.BYTES );
return unsafe.getChar( address );
}
代码示例来源:origin: apache/ignite
/**
* Gets char value from byte array. Alignment aware.
*
* @param arr Byte array.
* @param off Offset.
* @return Char value from byte array.
*/
public static char getChar(byte[] arr, long off) {
return UNALIGNED ? UNSAFE.getChar(arr, off) : getCharByByte(arr, off, BIG_ENDIAN);
}
代码示例来源:origin: apache/ignite
/**
* Gets char value from given address. Alignment aware.
*
* @param addr Address.
* @return Char value from given address.
*/
public static char getChar(long addr) {
return UNALIGNED ? UNSAFE.getChar(addr) : getCharByByte(addr, BIG_ENDIAN);
}
代码示例来源:origin: netty/netty
return ConstantTimeUtils.equalsConstantTime(result |
(UNSAFE.getInt(bytes1, baseOffset1 + 3) ^ UNSAFE.getInt(bytes2, baseOffset2 + 3)) |
(UNSAFE.getChar(bytes1, baseOffset1 + 1) ^ UNSAFE.getChar(bytes2, baseOffset2 + 1)) |
(UNSAFE.getByte(bytes1, baseOffset1) ^ UNSAFE.getByte(bytes2, baseOffset2)), 0);
case 6:
return ConstantTimeUtils.equalsConstantTime(result |
(UNSAFE.getInt(bytes1, baseOffset1 + 2) ^ UNSAFE.getInt(bytes2, baseOffset2 + 2)) |
(UNSAFE.getChar(bytes1, baseOffset1) ^ UNSAFE.getChar(bytes2, baseOffset2)), 0);
case 5:
return ConstantTimeUtils.equalsConstantTime(result |
case 3:
return ConstantTimeUtils.equalsConstantTime(result |
(UNSAFE.getChar(bytes1, baseOffset1 + 1) ^ UNSAFE.getChar(bytes2, baseOffset2 + 1)) |
(UNSAFE.getByte(bytes1, baseOffset1) ^ UNSAFE.getByte(bytes2, baseOffset2)), 0);
case 2:
return ConstantTimeUtils.equalsConstantTime(result |
(UNSAFE.getChar(bytes1, baseOffset1) ^ UNSAFE.getChar(bytes2, baseOffset2)), 0);
case 1:
return ConstantTimeUtils.equalsConstantTime(result |
代码示例来源:origin: real-logic/agrona
public char getChar(final int index)
{
boundsCheck0(index, SIZE_OF_CHAR);
return UNSAFE.getChar(byteArray, ARRAY_BASE_OFFSET + index);
}
代码示例来源:origin: real-logic/agrona
public char getChar(final int index)
{
if (SHOULD_BOUNDS_CHECK)
{
boundsCheck0(index, SIZE_OF_CHAR);
}
return UNSAFE.getChar(byteArray, addressOffset + index);
}
代码示例来源:origin: real-logic/agrona
public char getChar(final int index)
{
boundsCheck0(index, SIZE_OF_CHAR);
return UNSAFE.getChar(null, address + index);
}
代码示例来源:origin: real-logic/agrona
public char getChar(final long index)
{
if (SHOULD_BOUNDS_CHECK)
{
boundsCheck0(index, SIZE_OF_CHAR);
}
return UNSAFE.getChar(null, addressOffset + index);
}
代码示例来源:origin: apache/ignite
/**
* Gets char value from given address assuming that value stored in little-endian byte order and native byte order
* is big-endian. Alignment aware.
*
* @param addr Address.
* @return Char value from given address.
*/
public static char getCharLE(long addr) {
return UNALIGNED ? Character.reverseBytes(UNSAFE.getChar(addr)) : getCharByByte(addr, false);
}
代码示例来源:origin: apache/ignite
/**
* Gets char value from byte array assuming that value stored in little-endian byte order and native byte order
* is big-endian. Alignment aware.
*
* @param arr Byte array.
* @param off Offset.
* @return Char value from byte array.
*/
public static char getCharLE(byte[] arr, long off) {
return UNALIGNED ? Character.reverseBytes(UNSAFE.getChar(arr, off)) : getCharByByte(arr, off, false);
}
代码示例来源:origin: real-logic/agrona
public char getChar(final int index, final ByteOrder byteOrder)
{
boundsCheck0(index, SIZE_OF_SHORT);
char bits = UNSAFE.getChar(byteArray, ARRAY_BASE_OFFSET + index);
if (NATIVE_BYTE_ORDER != byteOrder)
{
bits = (char)Short.reverseBytes((short)bits);
}
return bits;
}
内容来源于网络,如有侵权,请联系作者删除!