STATIC void sn_store(pTHX_ HV *tb, const char *key, I32 klen, SV *val, U32 hash) {
#define sn_store(T, K, KL, V, H) sn_store(aTHX_ (T), (K), (KL), (V), (H))
- if (!hv_store(tb, key, klen, val, hash))
- SvREFCNT_dec(val);
+ if (!hv_store(tb, key, klen, val, hash)) SvREFCNT_dec(val);
}
STATIC void sn_store_ent(pTHX_ HV *tb, SV *key, SV *val, U32 hash) {
#define sn_store_ent(T, K, V, H) sn_store_ent(aTHX_ (T), (K), (V), (H))
- if (!hv_store_ent(tb, key, val, hash))
- SvREFCNT_dec(val);
+ if (!hv_store_ent(tb, key, val, hash)) SvREFCNT_dec(val);
}
} else {
hv = (HV *) SvRV(sv);
if (!hv_iterinit(hv)) {
- sn_store(res, "0", 1, newSVnv(c), 0);
+ XSRETURN_UNDEF;
} else {
hv_iterinit(hv);
while (key = hv_iternext(hv)) {
if (!SvOK(cur))
continue;
if (!SvROK(cur)) {
- if (strEQ(SvPV_nolen(cur), "list")) {
- hv_clear(res);
- sn_store(res, "list", 4, newSVuv(1), sn_hash_list);
- break;
- } else {
- NV v = 1;
- if ((old = hv_fetch_ent(res, cur, 1, 0)) && SvOK(val = HeVAL(old)))
- v += SvNV(val);
- sn_store_ent(res, cur, newSVnv(v), 0);
- continue;
- }
+ NV v = 1;
+ if ((old = hv_fetch_ent(res, cur, 1, 0)) && SvOK(val = HeVAL(old)))
+ v += SvNV(val);
+ sn_store_ent(res, cur, newSVnv(v), 0);
+ continue;
}
cur = SvRV(cur);
hv_iterinit((HV *) cur);
sv = SvRV(sv);
if (!hv_iterinit((HV *) sv))
XSRETURN_UNDEF;
- c = 1;
- a = c0;
- for (; n > 0; n /= 2) {
- if (n % 2)
- c *= a;
- a *= a;
+ if (c0 == 1 || (SvIOK(csv) && SvIV(csv) == 1)) {
+ c = n;
+ } else {
+ c = 1;
+ a = c0;
+ for (; n > 0; n /= 2) {
+ if (n % 2)
+ c *= a;
+ a *= a;
+ }
+ c = (1 - c) / (1 - c0);
}
- c = (1 - c) / (1 - c0);
res = newHV();
while (key = hv_iternext((HV *) sv)) {
SV *k = HeSVKEY_force(key);
res[0] = res[1] = NULL;
for (i = 0; i < items; ++i) {
cur = ST(i);
- if (!SvOK(cur))
+ if (!SvOK(cur))
continue;
if (!SvROK(cur)) {
if (strEQ(SvPV_nolen(cur), "list")) {
XSRETURN_UNDEF;
if (n == 1)
SvREFCNT_dec(res[0]);
- else if (res[1])
+ else if (res[1])
SvREFCNT_dec(res[1]);
ST(0) = sv_2mortal(newRV_noinc((SV *) res[n]));
XSRETURN(1);