On Sat, Sep 27, 2008 at 05:44:43AM -0700, Vasily Chekalkin wrote:
> --- a/languages/perl6/src/builtins/any-str.pir
> +++ b/languages/perl6/src/builtins/any-str.pir
> +
> +=item capitalize
> + [...]
> +=cut
> +
> +    .local int pos, is_ws, is_lc
> +    pos = 0
> +    goto first_char
> +  next_grapheme:
> +    if pos == len goto done
> +    is_ws = is_cclass .CCLASS_WHITESPACE, tmps, pos
> +    if is_ws goto ws
> +  advance:
> +    pos += 1
> +    goto next_grapheme
> +  ws:
> +    pos += 1
> +  first_char:
> +    is_lc = is_cclass .CCLASS_LOWERCASE, tmps, pos
> +    unless is_lc goto advance
> ...

This section of code would be much simpler (and more efficient)
by using the C<find_cclass> and C<find_not_cclass opcodes> instead of
individually examining each character one-at-a-time.

> +.sub 'chop' :method
> +    len = length tmps
> +    if len == 0 goto done
> +    dec len
> +    substr tmps,tmps, 0, len
> ...

PIR has a C<chop> opcode, perhaps we should use it?

Pm

Reply via email to