summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-06-28 12:17:38 +0200
committerNicholas Clark <nick@ccl4.org>2011-07-01 14:05:41 +0200
commitb606cf7f37b8b46206c7f521b29167e037397a62 (patch)
treee45fbf2581a952143dd7e8c7e6c34f9c25075c12 /pp.c
parent378b4d0f82057e5af983d31c5b48b7f10f4758b3 (diff)
downloadperl-b606cf7f37b8b46206c7f521b29167e037397a62.tar.gz
Store C<study>'s data as U32s, instead of I32s.
The "no more" condition is now represented as ~0, instead of -1.
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/pp.c b/pp.c
index 12ab9139bc..f177165a0f 100644
--- a/pp.c
+++ b/pp.c
@@ -707,9 +707,8 @@ PP(pp_study)
{
dVAR; dSP; dPOPss;
register unsigned char *s;
- register I32 ch;
- register I32 *sfirst;
- register I32 *snext;
+ U32 *sfirst;
+ U32 *snext;
STRLEN len;
MAGIC *mg = SvMAGICAL(sv) ? mg_find(sv, PERL_MAGIC_study) : NULL;
@@ -729,7 +728,7 @@ PP(pp_study)
RETPUSHNO;
}
- Newx(sfirst, 256 + len, I32);
+ Newx(sfirst, 256 + len, U32);
if (!sfirst)
DIE(aTHX_ "do_study: out of memory");
@@ -738,19 +737,15 @@ PP(pp_study)
if (!mg)
mg = sv_magicext(sv, NULL, PERL_MAGIC_study, &PL_vtbl_regexp, NULL, 0);
mg->mg_ptr = (char *) sfirst;
- mg->mg_len = (256 + len) * sizeof(I32);
+ mg->mg_len = (256 + len) * sizeof(U32);
- snext = sfirst;
- for (ch = 256; ch; --ch)
- *snext++ = -1;
+ snext = sfirst + 256;
+ memset(sfirst, ~0, 256 * sizeof(U32));
while (len-- > 0) {
const U8 ch = s[len];
- if (sfirst[ch] >= 0)
- snext[len] = sfirst[ch];
- else
- snext[len] = -1;
- sfirst[ch] = (I32)len;
+ snext[len] = sfirst[ch];
+ sfirst[ch] = len;
}
RETPUSHYES;