summaryrefslogtreecommitdiff
path: root/doop.c
diff options
context:
space:
mode:
authorJoshua Pritikin <joshua.pritikin@db.com>1998-06-15 06:03:37 -0400
committerGurusamy Sarathy <gsar@cpan.org>1998-06-20 23:47:09 +0000
commit800e9ae0504a9c74de77c7ab0037cc96b5df4995 (patch)
tree118b9d18a389b7dadbbf626bb92876116df977c5 /doop.c
parent270d1e3932d8fd3e603e87df650a603bf9eefa79 (diff)
downloadperl-800e9ae0504a9c74de77c7ab0037cc96b5df4995.tar.gz
added patch, tweaked missed files, excised comment that doesn't really
belong in the sources Message-Id: <H00000e500072c63@MHS> Subject: [PATCH 5.004_57] tied hash slice & do_kv cleanup p4raw-id: //depot/perl@1165
Diffstat (limited to 'doop.c')
-rw-r--r--doop.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/doop.c b/doop.c
index e527cdee18..8239c33c7c 100644
--- a/doop.c
+++ b/doop.c
@@ -445,6 +445,7 @@ do_kv(ARGSproto)
{
djSP;
HV *hv = (HV*)POPs;
+ HV *keys;
register HE *entry;
SV *tmpstr;
I32 gimme = GIMME_V;
@@ -465,10 +466,8 @@ do_kv(ARGSproto)
RETURN;
}
- if (realhv)
- (void)hv_iterinit(hv); /* always reset iterator regardless */
- else
- (void)avhv_iterinit((AV*)hv);
+ keys = realhv ? hv : avhv_keys((AV*)hv);
+ (void)hv_iterinit(keys); /* always reset iterator regardless */
if (gimme == G_VOID)
RETURN;
@@ -483,33 +482,31 @@ do_kv(ARGSproto)
sv_magic(TARG, Nullsv, 'k', Nullch, 0);
}
LvTYPE(TARG) = 'k';
- if (LvTARG(TARG) != (SV*)hv) {
+ if (LvTARG(TARG) != (SV*)keys) {
if (LvTARG(TARG))
SvREFCNT_dec(LvTARG(TARG));
- LvTARG(TARG) = SvREFCNT_inc(hv);
+ LvTARG(TARG) = SvREFCNT_inc(keys);
}
PUSHs(TARG);
RETURN;
}
- if (!SvRMAGICAL(hv) || !mg_find((SV*)hv,'P'))
- i = HvKEYS(hv);
+ if (!SvRMAGICAL(keys) || !mg_find((SV*)keys,'P'))
+ i = HvKEYS(keys);
else {
i = 0;
/*SUPPRESS 560*/
- while (entry = realhv ? hv_iternext(hv) : avhv_iternext((AV*)hv)) {
- i++;
- }
+ while (hv_iternext(keys)) i++;
}
PUSHi( i );
RETURN;
}
/* Guess how much room we need. hv_max may be a few too many. Oh well. */
- EXTEND(SP, HvMAX(hv) * (dokeys + dovalues));
+ EXTEND(SP, HvMAX(keys) * (dokeys + dovalues));
PUTBACK; /* hv_iternext and hv_iterval might clobber stack_sp */
- while (entry = realhv ? hv_iternext(hv) : avhv_iternext((AV*)hv)) {
+ while (entry = hv_iternext(keys)) {
SPAGAIN;
if (dokeys)
XPUSHs(hv_iterkeysv(entry)); /* won't clobber stack_sp */
@@ -520,8 +517,8 @@ do_kv(ARGSproto)
hv_iterval(hv,entry) : avhv_iterval((AV*)hv,entry));
DEBUG_H(sv_setpvf(tmpstr, "%lu%%%d=%lu",
(unsigned long)HeHASH(entry),
- HvMAX(hv)+1,
- (unsigned long)(HeHASH(entry) & HvMAX(hv))));
+ HvMAX(keys)+1,
+ (unsigned long)(HeHASH(entry) & HvMAX(keys))));
SPAGAIN;
XPUSHs(tmpstr);
}