diff options
author | Karl Williamson <khw@cpan.org> | 2017-12-08 10:20:24 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2017-12-08 22:27:44 -0700 |
commit | b40579ffada21adfc9e94a8d206592c7923a5bbe (patch) | |
tree | 6a5125649c3d2abcb5f8b51c69c6e8cf570250dc /inline.h | |
parent | 111bb90039d365ca2fbdae1ed5c1b03c4c37637a (diff) | |
download | perl-b40579ffada21adfc9e94a8d206592c7923a5bbe.tar.gz |
is_utf8_invariant_string(): small speed optimization
By pulling a test out of a while loop condition and doing it before the
while starts, we don't increase the number of conditionals; instead we
avoid doing the conditional each time through, and also skip
some conditionals for strings shorter than a word.
Diffstat (limited to 'inline.h')
-rw-r--r-- | inline.h | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -406,9 +406,11 @@ S_is_utf8_invariant_string_loc(const U8* const s, STRLEN len, const U8 ** ep) # error Unexpected word size # endif + if ((STRLEN) (send - x) >= PERL_WORDSIZE) { + /* Process per-byte until reach word boundary. XXX This loop could be * eliminated if we knew that this platform had fast unaligned reads */ - while (x < send && (PTR2nat(x) & PERL_WORD_BOUNDARY_MASK)) { + while (PTR2nat(x) & PERL_WORD_BOUNDARY_MASK) { if (! UTF8_IS_INVARIANT(*x)) { if (ep) { *ep = x; @@ -434,6 +436,7 @@ S_is_utf8_invariant_string_loc(const U8* const s, STRLEN len, const U8 ** ep) } x += PERL_WORDSIZE; } + } # undef PERL_WORDCAST # undef PERL_WORDSIZE |