develooper Front page | perl.perl5.porters | Postings from November 2005

XS-assisted SWASHGET (esp. for t/uni/class.t speedup)

Thread Next
From:
SADAHIRO Tomoyuki
Date:
November 23, 2005 00:55
Subject:
XS-assisted SWASHGET (esp. for t/uni/class.t speedup)
Message ID:
20051123175603.FFD5.BQW10602@nifty.com
Hello.

Perl internally uses swashes for retrieval of Unicode properties and
transliteration mappings, for example: \p{Letter}, tr/// for utf8, etc.
But one of its core operations, Perl_swash_fetch (in utf8.c), relies
on a pure perl method SWASHGET (in utf8_heavy.pl) which uses
many regex operations and seems to take more time.

Thus I have rewritten the functionality of SWASHGET in XS
and made SWASHGET in pure perl as a wrapper for the XS.
This XS (see the patch) is named utf8::SWASHGET_heavy and located
in universal.c, as well as other XS'es in utf8:: package are there:

sub SWASHGET {
    return utf8::SWASHGET_heavy($_[0], $_[1], $_[2], DEBUG);
}
(some comments in utf8_heavy.pl are omitted for clarity)


time for t/uni/class.t (not quite exact)

    perl-current:      about 32-33 sec
    with this patch:   about 12-13 sec

In particular, removal of save_re_context, PUSHSTACKi and POPSTACK
from Perl_swash_fetch seems to save much times.

The patch gzipped (against perl patch 26198) is attached to this mail
as swashget.patch.gz

Regards,
SADAHIRO Tomoyuki



Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About