public void fill(int fromIndex, int toIndex, long val) {assert fromIndex >= 0;assert fromIndex <= toIndex;assert PackedInts.unsignedBitsRequired(val) <= bitsPerValue;final int valuesPerBlock = 64 / bitsPerValue;if (toIndex - fromIndex <= valuesPerBlock << 1) {super.fill(fromIndex, toIndex, val);return;}int fromOffsetInBlock = fromIndex % valuesPerBlock;if (fromOffsetInBlock != 0) {for (int i = fromOffsetInBlock; i < valuesPerBlock; ++i) {set(fromIndex++, val);}assert fromIndex % valuesPerBlock == 0;}final int fromBlock = fromIndex / valuesPerBlock;final int toBlock = toIndex / valuesPerBlock;assert fromBlock * valuesPerBlock == fromIndex;long blockValue = 0L;for (int i = 0; i < valuesPerBlock; ++i) {blockValue = blockValue | (val << (i * bitsPerValue));}Arrays.fill(blocks, fromBlock, toBlock, blockValue);for (int i = valuesPerBlock * toBlock; i < toIndex; ++i) {set(i, val);}}

public override void Fill(int fromIndex, int toIndex, long val){Debug.Assert(fromIndex >= 0);Debug.Assert(fromIndex <= toIndex);Debug.Assert(PackedInt32s.BitsRequired(val) <= m_bitsPerValue);int valuesPerBlock = 64 / m_bitsPerValue;if (toIndex - fromIndex <= valuesPerBlock << 1){base.Fill(fromIndex, toIndex, val);return;}int fromOffsetInBlock = fromIndex % valuesPerBlock;if (fromOffsetInBlock != 0){for (int i = fromOffsetInBlock; i < valuesPerBlock; ++i){Set(fromIndex++, val);}Debug.Assert(fromIndex % valuesPerBlock == 0);}int fromBlock = fromIndex / valuesPerBlock;int toBlock = toIndex / valuesPerBlock;Debug.Assert(fromBlock * valuesPerBlock == fromIndex);long blockValue = 0L;for (int i = 0; i < valuesPerBlock; ++i){blockValue = blockValue | (val << (i * m_bitsPerValue));}Arrays.Fill(blocks, fromBlock, toBlock, blockValue);for (int i = valuesPerBlock * toBlock; i < toIndex; ++i){Set(i, val);}}
