/** * Returns and interned entry if possible, a new one otherwise. * <p> * The {@code byteBuf}'s {@link ByteBuf#readerIndex()} is incremented by {@code length} after it. */ public final O getOrCreate(final I value) { if (value == null) { return null; } final int hashCode = hashCode(value); //fast % operation with power of 2 entries.length final int firstIndex = hashCode & mask; final O firstEntry = entries[firstIndex]; if (isEqual(firstEntry, value)) { return firstEntry; } final int secondIndex = (hashCode >> shift) & mask; final O secondEntry = entries[secondIndex]; if (isEqual(secondEntry, value)) { return secondEntry; } final O internedEntry = create(value); final int entryIndex = firstEntry == null ? firstIndex : secondIndex; entries[entryIndex] = internedEntry; return internedEntry; } }
/** * Returns and interned entry if possible, a new one otherwise. * <p> * The {@code byteBuf}'s {@link ByteBuf#readerIndex()} is incremented by {@code length} after it. */ public final O getOrCreate(final I value) { if (value == null) { return null; } final int hashCode = hashCode(value); //fast % operation with power of 2 entries.length final int firstIndex = hashCode & mask; final O firstEntry = entries[firstIndex]; if (isEqual(firstEntry, value)) { return firstEntry; } final int secondIndex = (hashCode >> shift) & mask; final O secondEntry = entries[secondIndex]; if (isEqual(secondEntry, value)) { return secondEntry; } final O internedEntry = create(value); final int entryIndex = firstEntry == null ? firstIndex : secondIndex; entries[entryIndex] = internedEntry; return internedEntry; } }
/** * Returns and interned entry if possible, a new one otherwise. * <p> * The {@code byteBuf}'s {@link ByteBuf#readerIndex()} is incremented by {@code length} after it. */ public final O getOrCreate(final I value) { if (value == null) { return null; } final int hashCode = hashCode(value); //fast % operation with power of 2 entries.length final int firstIndex = hashCode & mask; final O firstEntry = entries[firstIndex]; if (isEqual(firstEntry, value)) { return firstEntry; } final int secondIndex = (hashCode >> shift) & mask; final O secondEntry = entries[secondIndex]; if (isEqual(secondEntry, value)) { return secondEntry; } final O internedEntry = create(value); final int entryIndex = firstEntry == null ? firstIndex : secondIndex; entries[entryIndex] = internedEntry; return internedEntry; } }
/** * Returns and interned entry if possible, a new one otherwise. * <p> * The {@code byteBuf}'s {@link ByteBuf#readerIndex()} is incremented by {@code length} after it. */ public final O getOrCreate(final I value) { if (value == null) { return null; } final int hashCode = hashCode(value); //fast % operation with power of 2 entries.length final int firstIndex = hashCode & mask; final O firstEntry = entries[firstIndex]; if (isEqual(firstEntry, value)) { return firstEntry; } final int secondIndex = (hashCode >> shift) & mask; final O secondEntry = entries[secondIndex]; if (isEqual(secondEntry, value)) { return secondEntry; } final O internedEntry = create(value); final int entryIndex = firstEntry == null ? firstIndex : secondIndex; entries[entryIndex] = internedEntry; return internedEntry; } }
/** * Returns and interned entry if possible, a new one otherwise. * <p> * The {@code byteBuf}'s {@link ByteBuf#readerIndex()} is incremented by {@code length} after it. */ public final O getOrCreate(final I value) { if (value == null) { return null; } final int hashCode = hashCode(value); //fast % operation with power of 2 entries.length final int firstIndex = hashCode & mask; final O firstEntry = entries[firstIndex]; if (isEqual(firstEntry, value)) { return firstEntry; } final int secondIndex = (hashCode >> shift) & mask; final O secondEntry = entries[secondIndex]; if (isEqual(secondEntry, value)) { return secondEntry; } final O internedEntry = create(value); final int entryIndex = firstEntry == null ? firstIndex : secondIndex; entries[entryIndex] = internedEntry; return internedEntry; } }
/** * Returns and interned entry if possible, a new one otherwise. * <p> * The {@code byteBuf}'s {@link ByteBuf#readerIndex()} is incremented by {@code length} after it. */ public final O getOrCreate(final I value) { if (value == null) { return null; } final int hashCode = hashCode(value); //fast % operation with power of 2 entries.length final int firstIndex = hashCode & mask; final O firstEntry = entries[firstIndex]; if (isEqual(firstEntry, value)) { return firstEntry; } final int secondIndex = (hashCode >> shift) & mask; final O secondEntry = entries[secondIndex]; if (isEqual(secondEntry, value)) { return secondEntry; } final O internedEntry = create(value); final int entryIndex = firstEntry == null ? firstIndex : secondIndex; entries[entryIndex] = internedEntry; return internedEntry; } }
/** * Returns and interned entry if possible, a new one otherwise. * <p> * The {@code byteBuf}'s {@link ByteBuf#readerIndex()} is incremented by {@code length} after it. */ public final O getOrCreate(final I value) { if (value == null) { return null; } final int hashCode = hashCode(value); //fast % operation with power of 2 entries.length final int firstIndex = hashCode & mask; final O firstEntry = entries[firstIndex]; if (isEqual(firstEntry, value)) { return firstEntry; } final int secondIndex = (hashCode >> shift) & mask; final O secondEntry = entries[secondIndex]; if (isEqual(secondEntry, value)) { return secondEntry; } final O internedEntry = create(value); final int entryIndex = firstEntry == null ? firstIndex : secondIndex; entries[entryIndex] = internedEntry; return internedEntry; } }