This does two things. First, it conflates the RV and non-RV cases; i.e.
if (ROK) {
sv = RV(sv)
if (REGEXP) rx = sv;
else if (PERL_MAGIC_qr) rx = mg_obj;
}
else {
if (REGEXP) rx = sv;
else if (PERL_MAGIC_qr) rx = mg_obj;
}
becomes
if (ROK)
sv = RV(sv)
if (REGEXP) rx = sv;
else if (PERL_MAGIC_qr) rx = mg_obj;
Secondly, elmininate the intermediate rx var; it's only point in life is
to be assigned to re_sv, so just use re_sv throughout.
{
/* extract RE object from returned value; compiling if
* necessary */
{
/* extract RE object from returned value; compiling if
* necessary */
- MAGIC *mg = NULL;
- REGEXP *rx = NULL;
-
- if (SvROK(ret)) {
- SV *const sv = SvRV(ret);
+ re_sv = NULL;
+ {
+ SV *sv = ret;
+ if (SvROK(sv))
+ sv = SvRV(sv);
if (SvTYPE(sv) == SVt_REGEXP) {
if (SvTYPE(sv) == SVt_REGEXP) {
} else if (SvSMAGICAL(sv)) {
} else if (SvSMAGICAL(sv)) {
- mg = mg_find(sv, PERL_MAGIC_qr);
+ MAGIC *mg = mg_find(sv, PERL_MAGIC_qr);
+ if (mg)
+ re_sv = (REGEXP *) mg->mg_obj;
- } else if (SvTYPE(ret) == SVt_REGEXP) {
- rx = (REGEXP*) ret;
- } else if (SvSMAGICAL(ret)) {
- mg = mg_find(ret, PERL_MAGIC_qr);
- }
-
- if (mg) {
- rx = (REGEXP *) mg->mg_obj; /*XXX:dmq*/
- assert(rx);
- if (rx) {
- rx = reg_temp_copy(NULL, rx);
+ if (re_sv) {
+ re_sv = reg_temp_copy(NULL, re_sv);
}
else {
U32 pm_flags = 0;
}
else {
U32 pm_flags = 0;
/* if we got here, it should be an engine which
* supports compiling code blocks and stuff */
assert(rex->engine && rex->engine->op_comp);
/* if we got here, it should be an engine which
* supports compiling code blocks and stuff */
assert(rex->engine && rex->engine->op_comp);
- rx = rex->engine->op_comp(aTHX_ &ret, 1, NULL,
+ re_sv = rex->engine->op_comp(aTHX_ &ret, 1, NULL,
rex->engine, NULL, NULL, 0, pm_flags);
if (!(SvFLAGS(ret)
rex->engine, NULL, NULL, 0, pm_flags);
if (!(SvFLAGS(ret)
/* This isn't a first class regexp. Instead, it's
caching a regexp onto an existing, Perl visible
scalar. */
/* This isn't a first class regexp. Instead, it's
caching a regexp onto an existing, Perl visible
scalar. */
- sv_magic(ret, MUTABLE_SV(rx), PERL_MAGIC_qr, 0, 0);
+ sv_magic(ret, MUTABLE_SV(re_sv), PERL_MAGIC_qr, 0, 0);
}
PL_regsize = osize;
/* safe to do now that any $1 etc has been
}
PL_regsize = osize;
/* safe to do now that any $1 etc has been
* compiled */
S_regcp_restore(aTHX_ rex, runops_cp);
}
* compiled */
S_regcp_restore(aTHX_ rex, runops_cp);
}
- re_sv = rx;
- re = (struct regexp *)SvANY(rx);
+ re = (struct regexp *)SvANY(re_sv);
}
RXp_MATCH_COPIED_off(re);
re->subbeg = rex->subbeg;
}
RXp_MATCH_COPIED_off(re);
re->subbeg = rex->subbeg;