public static InternalSearchData CreateSearchData(byte[] values) { InternalSearchData sd = new InternalSearchData(); sd.checkB0 = new bool[256]; for (int i = 0; i < values.Length; ++i) { sd.checkB0[values[i]] = true; } return(sd); }
public unsafe bool TryFindAnyForward(long pos, InternalSearchData sd, out long foundAt) { foundAt = -1; long curIdx = pos - begin; long length = end - begin; if (curIdx < 0 || curIdx >= length) { return(false); } if (begin < 0 || length < 0) { return(false); } if (sd.checkB0 == null || sd.checkB0.Length != 256) { return(false); } if (byteBuffer == null || byteBuffer.Length < length) { return(false); fixed(byte *buffer = byteBuffer) { fixed(bool *chk = sd.checkB0) { byte *bEnd = buffer + length; byte *bCur = buffer + curIdx; while (bCur < bEnd) { if (*(chk + *(bCur))) { foundAt = begin + (bCur - buffer); return(true); } ++bCur; } } } return(false); }