gv = (GV*)gv_fetchsv(sv, TRUE, SVt_PV);
}
}
- sv = GvSV(gv);
+ sv = GvSVn(gv);
}
if (PL_op->op_flags & OPf_MOD) {
if (PL_op->op_private & OPpLVAL_INTRO) {
const char *pv;
SV * const sv = POPs;
- if (sv && SvGMAGICAL(sv))
- mg_get(sv);
+ if (sv)
+ SvGETMAGIC(sv);
if (!sv || !SvROK(sv))
RETPUSHNO;
if (ssv && !SvGMAGICAL(ssv) && !SvAMAGIC(ssv) && SvROK(ssv))
Perl_croak(aTHX_ "Attempt to bless into a reference");
ptr = SvPV_const(ssv,len);
- if (ckWARN(WARN_MISC) && len == 0)
+ if (len == 0 && ckWARN(WARN_MISC))
Perl_warner(aTHX_ packWARN(WARN_MISC),
"Explicit blessing to '' (assuming package main)");
stash = gv_stashpvn(ptr, len, TRUE);
if (pos > PL_maxscream) {
if (PL_maxscream < 0) {
PL_maxscream = pos + 80;
- New(301, PL_screamfirst, 256, I32);
- New(302, PL_screamnext, PL_maxscream, I32);
+ Newx(PL_screamfirst, 256, I32);
+ Newx(PL_screamnext, PL_maxscream, I32);
}
else {
PL_maxscream = pos + pos / 4;
RETPUSHYES;
break;
default:
- if (SvGMAGICAL(sv))
- mg_get(sv);
+ SvGETMAGIC(sv);
if (SvOK(sv))
RETPUSHYES;
}
hv_undef((HV*)sv);
break;
case SVt_PVCV:
- if (ckWARN(WARN_MISC) && cv_const_sv((CV*)sv))
+ if (cv_const_sv((CV*)sv) && ckWARN(WARN_MISC))
Perl_warner(aTHX_ packWARN(WARN_MISC), "Constant subroutine %s undefined",
CvANON((CV*)sv) ? "(anonymous)" : GvENAME(CvGV((CV*)sv)));
/* FALL THROUGH */
else {
GP *gp;
gp_free((GV*)sv);
- Newz(602, gp, 1, GP);
+ Newxz(gp, 1, GP);
GvGP(sv) = gp_ref(gp);
GvSV(sv) = NEWSV(72,0);
GvLINE(sv) = CopLINE(PL_curcop);
we're sure it is safe; otherwise we call pow() and try to convert to
integer afterwards. */
{
- SvIV_please(TOPm1s);
- if (SvIOK(TOPm1s)) {
- bool baseuok = SvUOK(TOPm1s);
- UV baseuv;
+ SvIV_please(TOPs);
+ if (SvIOK(TOPs)) {
+ SvIV_please(TOPm1s);
+ if (SvIOK(TOPm1s)) {
+ UV power;
+ bool baseuok;
+ UV baseuv;
- if (baseuok) {
- baseuv = SvUVX(TOPm1s);
- } else {
- const IV iv = SvIVX(TOPm1s);
- if (iv >= 0) {
- baseuv = iv;
- baseuok = TRUE; /* effectively it's a UV now */
- } else {
- baseuv = -iv; /* abs, baseuok == false records sign */
- }
- }
- SvIV_please(TOPs);
- if (SvIOK(TOPs)) {
- UV power;
+ if (SvUOK(TOPs)) {
+ power = SvUVX(TOPs);
+ } else {
+ const IV iv = SvIVX(TOPs);
+ if (iv >= 0) {
+ power = iv;
+ } else {
+ goto float_it; /* Can't do negative powers this way. */
+ }
+ }
- if (SvUOK(TOPs)) {
- power = SvUVX(TOPs);
- } else {
- IV iv = SvIVX(TOPs);
- if (iv >= 0) {
- power = iv;
- } else {
- goto float_it; /* Can't do negative powers this way. */
- }
- }
+ baseuok = SvUOK(TOPm1s);
+ if (baseuok) {
+ baseuv = SvUVX(TOPm1s);
+ } else {
+ const IV iv = SvIVX(TOPm1s);
+ if (iv >= 0) {
+ baseuv = iv;
+ baseuok = TRUE; /* effectively it's a UV now */
+ } else {
+ baseuv = -iv; /* abs, baseuok == false records sign */
+ }
+ }
/* now we have integer ** positive integer. */
is_int = 1;
programmers to notice ** not doing what they mean. */
NV result = 1.0;
NV base = baseuok ? baseuv : -(NV)baseuv;
- int n = 0;
-
- for (; power; base *= base, n++) {
- /* Do I look like I trust gcc with long longs here?
- Do I hell. */
- const UV bit = (UV)1 << (UV)n;
- if (power & bit) {
- result *= base;
- /* Only bother to clear the bit if it is set. */
- power -= bit;
- /* Avoid squaring base again if we're done. */
- if (power == 0) break;
- }
- }
+
+ if (power & 1) {
+ result *= base;
+ }
+ while (power >>= 1) {
+ base *= base;
+ if (power & 1) {
+ result *= base;
+ }
+ }
SP--;
SETn( result );
SvIV_please(TOPs);
RETURN;
} else {
register unsigned int highbit = 8 * sizeof(UV);
- register unsigned int lowbit = 0;
- register unsigned int diff;
- bool odd_power = (bool)(power & 1);
- while ((diff = (highbit - lowbit) >> 1)) {
- if (baseuv & ~((1 << (lowbit + diff)) - 1))
- lowbit += diff;
- else
- highbit -= diff;
+ register unsigned int diff = 8 * sizeof(UV);
+ while (diff >>= 1) {
+ highbit -= diff;
+ if (baseuv >> highbit) {
+ highbit += diff;
+ }
}
/* we now have baseuv < 2 ** highbit */
if (power * highbit <= 8 * sizeof(UV)) {
on same algorithm as above */
register UV result = 1;
register UV base = baseuv;
- register int n = 0;
- for (; power; base *= base, n++) {
- register const UV bit = (UV)1 << (UV)n;
- if (power & bit) {
+ const bool odd_power = (bool)(power & 1);
+ if (odd_power) {
+ result *= base;
+ }
+ while (power >>= 1) {
+ base *= base;
+ if (power & 1) {
result *= base;
- power -= bit;
- if (power == 0) break;
}
}
SP--;
{
register IV count;
dPOPss;
- if (SvGMAGICAL(sv))
- mg_get(sv);
+ SvGETMAGIC(sv);
if (SvIOKp(sv)) {
if (SvUOK(sv)) {
const UV uv = SvUV(sv);
dSP; dATARGET; tryAMAGICbin(band,opASSIGN);
{
dPOPTOPssrl;
- if (SvGMAGICAL(left)) mg_get(left);
- if (SvGMAGICAL(right)) mg_get(right);
+ SvGETMAGIC(left);
+ SvGETMAGIC(right);
if (SvNIOKp(left) || SvNIOKp(right)) {
if (PL_op->op_private & HINT_INTEGER) {
const IV i = SvIV_nomg(left) & SvIV_nomg(right);
dSP; dATARGET; tryAMAGICbin(bxor,opASSIGN);
{
dPOPTOPssrl;
- if (SvGMAGICAL(left)) mg_get(left);
- if (SvGMAGICAL(right)) mg_get(right);
+ SvGETMAGIC(left);
+ SvGETMAGIC(right);
if (SvNIOKp(left) || SvNIOKp(right)) {
if (PL_op->op_private & HINT_INTEGER) {
const IV i = (USE_LEFT(left) ? SvIV_nomg(left) : 0) ^ SvIV_nomg(right);
dSP; dATARGET; tryAMAGICbin(bor,opASSIGN);
{
dPOPTOPssrl;
- if (SvGMAGICAL(left)) mg_get(left);
- if (SvGMAGICAL(right)) mg_get(right);
+ SvGETMAGIC(left);
+ SvGETMAGIC(right);
if (SvNIOKp(left) || SvNIOKp(right)) {
if (PL_op->op_private & HINT_INTEGER) {
const IV i = (USE_LEFT(left) ? SvIV_nomg(left) : 0) | SvIV_nomg(right);
{
dTOPss;
const int flags = SvFLAGS(sv);
- if (SvGMAGICAL(sv))
- mg_get(sv);
+ SvGETMAGIC(sv);
if ((flags & SVf_IOK) || ((flags & (SVp_IOK | SVp_NOK)) == SVp_IOK)) {
/* It's publicly an integer, or privately an integer-not-float */
oops_its_an_int:
dSP; dTARGET; tryAMAGICun(compl);
{
dTOPss;
- if (SvGMAGICAL(sv))
- mg_get(sv);
+ SvGETMAGIC(sv);
if (SvNIOKp(sv)) {
if (PL_op->op_private & HINT_INTEGER) {
const IV i = ~SvIV_nomg(sv);
tmps -= len;
if (nwide) {
- Newz(0, result, targlen + 1, U8);
+ Newxz(result, targlen + 1, U8);
while (tmps < send) {
const UV c = utf8n_to_uvchr(tmps, send-tmps, &l, UTF8_ALLOW_ANYUV);
tmps += UTF8SKIP(tmps);
SvUTF8_on(TARG);
}
else {
- Newz(0, result, nchar + 1, U8);
+ Newxz(result, nchar + 1, U8);
while (tmps < send) {
const U8 c = (U8)utf8n_to_uvchr(tmps, 0, &l, UTF8_ALLOW_ANY);
tmps += UTF8SKIP(tmps);
} else{
const NV value = TOPn;
if (value < 0.0)
- SETn(value);
- else
SETn(-value);
+ else
+ SETn(value);
}
}
RETURN;
if (diff < 0) { /* shrinking the area */
if (newlen) {
- New(451, tmparyval, newlen, SV*); /* so remember insertion */
+ Newx(tmparyval, newlen, SV*); /* so remember insertion */
Copy(MARK, tmparyval, newlen, SV*);
}
}
else { /* no, expanding (or same) */
if (length) {
- New(452, tmparyval, length, SV*); /* so remember deletion */
+ Newx(tmparyval, length, SV*); /* so remember deletion */
Copy(AvARRAY(ary)+offset, tmparyval, length, SV*);
}