Example usage for io.netty.util.internal PlatformDependent getShort

List of usage examples for io.netty.util.internal PlatformDependent getShort

Introduction

In this page you can find the example usage for io.netty.util.internal PlatformDependent getShort.

Prototype

public static short getShort(byte[] data, int index) 

Source Link

Usage

From source file:org.apache.activemq.artemis.utils.AbstractByteBufPool.java

License:Apache License

private static int onHeapHashCode(final byte[] bytes, final int offset, final int length) {
    final int intCount = length >>> 1;
    final int byteCount = length & 1;
    int hashCode = 1;
    int arrayIndex = offset;
    for (int i = 0; i < intCount; i++) {
        hashCode = 31 * hashCode + PlatformDependent.getShort(bytes, arrayIndex);
        arrayIndex += 2;/*from   w w w  . j  a v a  2s  . c  om*/
    }
    for (int i = 0; i < byteCount; i++) {
        hashCode = 31 * hashCode + PlatformDependent.getByte(bytes, arrayIndex++);
    }
    return hashCode;
}