[RFC] Possible PCT performance improvements.

chromatic chromatic at wgz.org
Sun Aug 15 23:17:51 UTC 2010


On Saturday 14 August 2010 at 16:38, Patrick R wrote:

> I've suggested a "compare substring at position" opcode several times,
> but so far nobody (including myself) seems to have found the tuits to
> create it.
> 
> If/when the opcode is added, I'll gladly fix up NQP and the regex engine
> to take advantage of it.  Ideally I'd like something like:
> 
>     $I0 = substreq $S0, $S1, $I1
> 
> which should mean something along the lines of
> 
>     Compare the string in $S0 with an equivalent-length substring of
>     $S1 starting at position $I1; return true if matched and false 
>     otherwise.

I have a patch which adds a new API function called 
Parrot_str_compare_offset().  It takes two strings and an offset within the first 
string at which to start the comparison.  If the contents of the first string 
at that offset position match the entire contents of the second string, it 
returns a true value.

We could add an experimental opcode around this function trivially.

Here's a diff which doesn't include tests, as there's no PIR-visible support 
yet.

-- c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: str_compare_offset.patch
Type: text/x-patch
Size: 10733 bytes
Desc: not available
URL: <http://lists.parrot.org/pipermail/parrot-dev/attachments/20100815/e43190ba/attachment.bin>


More information about the parrot-dev mailing list