Open
Description
Split out of #966 for tracking, see that PR for more background detail.
Add a new FindArrayInArray
native that takes an array of bytes to search for along with an offset to start matching from.
FindValueInArray(arr, 42, 1, 2);
would become FindArrayInArray(arr, { 42, 42 }, 2, 1);
But this design also allows more flexible combinations such as FindArrayInArray(arr, { 11, 42 }, 2, 1);
And if we specify an additional limit
param and wrap access to the input array, the first example can be simplified to: FindArrayInArray(arr, { 42 }, 1, 1, 2);
native int FindArrayInArray(Handle array, any[] needle, int needleLength, int start = 0, int limit = 0);
Where:
needle
= the bytes to search.start
= the byte offset in each block to start searching.limit
= the number of bytes of the block to match, loopingneedle
as needed, with the following special values:-1
= the block size -start
0
=needleLength
needleLength
>limit
would be an error.limit
> (block size -start
) would be an error.- 0 <
start
<= block size would be an error.