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

Method SearchCommon

src/program/Signature.cpp:236–265  ·  view source on GitHub ↗

Reference version search

Source from the content-addressed store, hash-verified

234
235// Reference version search
236int SigSearch::SearchCommon(uint8_t* input, size_t inputLen, const Signature &sig, ptrdiff_t* output_offset)
237{
238 size_t sigSize = sig.bytes.size();
239 size_t len = inputLen - sigSize;
240 size_t count = 0;
241 bool hasWildcards = sig.hasMask();
242
243 inputLen -= sigSize;
244
245 // Search for signature match..
246 uint8_t* match = FindCommon(input, len, sig, hasWildcards);
247 while (match)
248 {
249 *output_offset = (ptrdiff_t) (match - input);
250 ++count;
251 // Stop now if we've hit two matches
252 // if (++count >= 2)
253 // break;
254
255 ++match;
256 len = (inputLen - (int) (match - input));
257 if (len < sigSize)
258 break;
259
260 // Next search
261 match = FindCommon(match, len, sig, hasWildcards);
262 };
263
264 return count;
265}
266
267// Fast AVX2 based search
268int SigSearch::SearchAVX2(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