MCPcopy Create free account
hub / github.com/clementgallet/libTAS / SearchAVX2

Method SearchAVX2

src/program/Signature.cpp:268–294  ·  view source on GitHub ↗

Fast AVX2 based search

Source from the content-addressed store, hash-verified

266
267// Fast AVX2 based search
268int SigSearch::SearchAVX2(uint8_t* input, size_t inputLen, const Signature &sig, ptrdiff_t* output_offset)
269{
270 size_t sigSize = sig.bytes.size();
271 size_t len = inputLen - sigSize;
272 size_t count = 0;
273 bool hasWildcards = sig.hasMask();
274
275 inputLen -= sigSize;
276
277 uint8_t* match = FindAVX2(input, len, sig, hasWildcards);
278 while (match)
279 {
280 *output_offset = (ptrdiff_t) (match - input);
281 ++count;
282 // if (++count >= 2)
283 // break;
284
285 ++match;
286 len = (inputLen - (int) (match - input));
287 if (len < sigSize)
288 break;
289
290 match = FindAVX2(match, len, sig, hasWildcards);
291 };
292
293 return count;
294}
295
296// Search for signature pattern, returning a status result
297int SigSearch::Search(uint8_t* input, size_t inputLen, const Signature &sig, ptrdiff_t* output_offset)

Callers

nothing calls this directly

Calls 2

hasMaskMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected