Java Code Examples for io.netty.util.internal.PlatformDependent#hashCodeAscii()

The following examples show how to use io.netty.util.internal.PlatformDependent#hashCodeAscii() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AsciiString.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * <p>
 * Provides a case-insensitive hash code for Ascii like byte strings.
 */
@Override
public int hashCode() {
    int h = hash;
    if (h == 0) {
        h = PlatformDependent.hashCodeAscii(value, offset, length);
        hash = h;
    }
    return h;
}
 
Example 2
Source File: AsciiString.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the case-insensitive hash code of the specified string. Note that this method uses the same hashing
 * algorithm with {@link #hashCode()} so that you can put both {@link AsciiString}s and arbitrary
 * {@link CharSequence}s into the same headers.
 */
public static int hashCode(CharSequence value) {
    if (value == null) {
        return 0;
    }
    if (value.getClass() == AsciiString.class) {
        return value.hashCode();
    }

    return PlatformDependent.hashCodeAscii(value);
}
 
Example 3
Source File: AsciiStringBenchmark.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
@Benchmark
public int hashCodeBenchBytesNew() {
    return PlatformDependent.hashCodeAscii(asciiString.array(), asciiString.arrayOffset(), asciiString.length());
}
 
Example 4
Source File: AsciiStringBenchmark.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
@Benchmark
public int hashCodeBenchCharSequenceNew() {
    return PlatformDependent.hashCodeAscii(string);
}