diff options
author | Nicholas Clark <nick@ccl4.org> | 2011-06-27 21:13:39 +0200 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2011-07-01 14:05:41 +0200 |
commit | 378b4d0f82057e5af983d31c5b48b7f10f4758b3 (patch) | |
tree | 1a8e6ff11898d44603e82e97cbd2c6da181020d7 /util.c | |
parent | 4185c9197f4aefd1943fba0b9999fc3200fd902c (diff) | |
download | perl-378b4d0f82057e5af983d31c5b48b7f10f4758b3.tar.gz |
Tidy code in pp_study and Perl_screaminstr()
In pp_study eliminate the variable pos, which duplicates len. ch should be U8,
not I32.
In Perl_screaminstr(), move the declarations of s and x to their point of use,
convert a for loop to a while loop, and avoid incrementing and decrementing s.
found is a boolean.
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -860,7 +860,7 @@ Perl_screaminstr(pTHX_ SV *bigstr, SV *littlestr, I32 start_shift, I32 end_shift register const unsigned char *little; register I32 stop_pos; register const unsigned char *littleend; - I32 found = 0; + bool found = FALSE; const MAGIC * mg; I32 *screamfirst; I32 *screamnext; @@ -916,19 +916,19 @@ Perl_screaminstr(pTHX_ SV *bigstr, SV *littlestr, I32 start_shift, I32 end_shift } big -= previous; do { - register const unsigned char *s, *x; if (pos >= stop_pos) break; if (big[pos] == first) { - for (x=big+pos+1,s=little; s < littleend; /**/ ) { - if (*s++ != *x++) { - s--; + const unsigned char *s = little; + const unsigned char *x = big + pos + 1; + while (s < littleend) { + if (*s != *x++) break; - } + ++s; } if (s == littleend) { *old_posp = pos; if (!last) return (char *)(big+pos); - found = 1; + found = TRUE; } } pos = screamnext[pos]; |