List of usage examples for io.netty.util.internal PlatformDependent isUnaligned
public static boolean isUnaligned()
From source file:org.apache.activemq.artemis.utils.AbstractByteBufPool.java
License:Apache License
/** * Batch hash code implementation that works at its best if {@code bytes} * contains a {@link org.apache.activemq.artemis.api.core.SimpleString} encoded. *///from w w w. j a v a 2 s . c om private static int hashCode(final ByteBuf bytes, final int offset, final int length) { if (PlatformDependent.isUnaligned() && PlatformDependent.hasUnsafe()) { //if the platform allows it, the hash code could be computed without bounds checking if (bytes.hasArray()) { return onHeapHashCode(bytes.array(), bytes.arrayOffset() + offset, length); } else if (bytes.hasMemoryAddress()) { return offHeapHashCode(bytes.memoryAddress(), offset, length); } } return byteBufHashCode(bytes, offset, length); }