diff options
author | Nicholas Clark <nick@ccl4.org> | 2006-03-22 22:49:42 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2006-03-22 22:49:42 +0000 |
commit | 75c33c120988d1ac9c551ac7361ab5df33793713 (patch) | |
tree | 1d096dfe2e8456313232ed60b58a5506b492448a /sv.c | |
parent | c336ad0b0ffc3d19ec24d23d8bc7a30158ac1ae5 (diff) | |
download | perl-75c33c120988d1ac9c551ac7361ab5df33793713.tar.gz |
Take advantage of uoffset >= uoffset0, to simplify some logic.
p4raw-id: //depot/perl@27574
Diffstat (limited to 'sv.c')
-rw-r--r-- | sv.c | 24 |
1 files changed, 13 insertions, 11 deletions
@@ -5545,25 +5545,27 @@ S_sv_pos_u2b_cached(pTHX_ SV *sv, MAGIC **mgp, const U8 *const start, STRLEN boffset; bool found = FALSE; + assert (uoffset >= uoffset0); + if (SvMAGICAL(sv) && !SvREADONLY(sv) && PL_utf8cache && (*mgp = mg_find(sv, PERL_MAGIC_utf8))) { if ((*mgp)->mg_len != -1) { - boffset = S_sv_pos_u2b_midway(aTHX_ start, send, uoffset, - (*mgp)->mg_len); + /* If we can take advantage of a passed in offset, do so. */ + /* In fact, offset0 is either 0, or less than offset, so don't + need to worry about the other possibility. */ + boffset = boffset0 + + S_sv_pos_u2b_midway(aTHX_ start + boffset0, send, + uoffset - uoffset0, + (*mgp)->mg_len - uoffset0); found = TRUE; } } if (!found || PL_utf8cache < 0) { - STRLEN real_boffset; - if (uoffset >= uoffset0) { - real_boffset - = boffset0 + S_sv_pos_u2b_forwards(aTHX_ start + boffset0, - send, uoffset - uoffset0); - } - else { - real_boffset = S_sv_pos_u2b_forwards(aTHX_ start, send, uoffset); - } + const STRLEN real_boffset + = boffset0 + S_sv_pos_u2b_forwards(aTHX_ start + boffset0, + send, uoffset - uoffset0); + if (found && PL_utf8cache < 0) { if (real_boffset != boffset) { /* Need to turn the assertions off otherwise we may recurse |